11 #include "threads/Condition.h" 14 #include <shared_mutex> 24 unsigned int sharedCount = 0;
31 std::unique_lock<CCriticalSection> l(sec);
33 actualCv.wait(l, [
this]() {
return sharedCount == 0; });
36 inline bool try_lock() {
return (sec.try_lock() ? ((sharedCount == 0) ?
true : (sec.unlock(),
false)) :
false); }
37 inline void unlock() { sec.unlock(); }
39 inline void lock_shared()
41 std::unique_lock<CCriticalSection> l(sec);
44 inline bool try_lock_shared() {
return (sec.try_lock() ? sharedCount++, sec.unlock(), true :
false); }
45 inline void unlock_shared()
47 std::unique_lock<CCriticalSection> l(sec);
This is a thin wrapper around std::condition_variable_any.
Definition: Condition.h:26
A CSharedSection is a mutex that satisfies the Shared Lockable concept (see Lockables.h).
Definition: SharedSection.h:19