Stroika Library 3.0d23
 
Loading...
Searching...
No Matches
NullLock.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_NullLock_h_
5#define _Stroika_Foundation_Execution_NullLock_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <mutex>
10
11#include "Stroika/Foundation/Common/Common.h"
13
14/*
15 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
16 */
17
19
20 /**
21 * This class follows the Mutex concept - syntactically - but doesn't actually perform locking.
22 *
23 * Sometimes you want to write code that can use locks or not. Use of the NullLock allows the syntax of
24 * locking to be present, but effectively all compiled (even constexpr) away.
25 *
26 * \note before Stroika v3.0d23 - this was called NullMutex
27 */
28 struct NullLock {
29 constexpr void lock () const;
30 constexpr bool try_lock () const;
31 constexpr void unlock () const;
32 constexpr void lock_shared () const;
33 constexpr bool try_lock_shared () const;
34 constexpr void unlock_shared () const;
35 };
37
38}
39
40/*
41 ********************************************************************************
42 ***************************** Implementation Details ***************************
43 ********************************************************************************
44 */
45#include "NullLock.inl"
46
47#endif /*_Stroika_Foundation_Execution_NullLock_h_*/
Logically the C++ standard Lockable named requirement, but that was not included in std c++ library.
Definition StdCompat.h:77