12#include <shared_mutex>
20using std::shared_mutex;
23using std::shared_lock;
24using std::unique_lock;
26#ifdef JPH_PLATFORM_BLUE
34 JPH_PLATFORM_BLUE_MUTEX_INIT(mMutex);
39 JPH_PLATFORM_BLUE_MUTEX_DESTROY(mMutex);
42 inline bool try_lock()
44 return JPH_PLATFORM_BLUE_MUTEX_TRYLOCK(mMutex);
49 JPH_PLATFORM_BLUE_MUTEX_LOCK(mMutex);
54 JPH_PLATFORM_BLUE_MUTEX_UNLOCK(mMutex);
58 JPH_PLATFORM_BLUE_MUTEX mMutex;
67 JPH_PLATFORM_BLUE_RWLOCK_INIT(mRWLock);
72 JPH_PLATFORM_BLUE_RWLOCK_DESTROY(mRWLock);
75 inline bool try_lock()
77 return JPH_PLATFORM_BLUE_RWLOCK_TRYWLOCK(mRWLock);
80 inline bool try_lock_shared()
82 return JPH_PLATFORM_BLUE_RWLOCK_TRYRLOCK(mRWLock);
87 JPH_PLATFORM_BLUE_RWLOCK_WLOCK(mRWLock);
92 JPH_PLATFORM_BLUE_RWLOCK_WUNLOCK(mRWLock);
95 inline void lock_shared()
97 JPH_PLATFORM_BLUE_RWLOCK_RLOCK(mRWLock);
100 inline void unlock_shared()
102 JPH_PLATFORM_BLUE_RWLOCK_RUNLOCK(mRWLock);
106 JPH_PLATFORM_BLUE_RWLOCK mRWLock;
117#if defined(JPH_ENABLE_ASSERTS) || defined(JPH_PROFILE_ENABLED) || defined(JPH_EXTERNAL_PROFILE)
126 JPH_ASSERT(mLockedThreadID != std::this_thread::get_id());
127 if (MutexBase::try_lock())
147 JPH_ASSERT(mLockedThreadID == std::this_thread::get_id());
152#ifdef JPH_ENABLE_ASSERTS
153 inline bool is_locked()
155 return mLockedThreadID != thread::id();
170 JPH_ASSERT(mLockedThreadID != std::this_thread::get_id());
171 if (SharedMutexBase::try_lock())
184 SharedMutexBase::lock();
191 JPH_ASSERT(mLockedThreadID == std::this_thread::get_id());
193 SharedMutexBase::unlock();
196#ifdef JPH_ENABLE_ASSERTS
197 inline bool is_locked()
199 return mLockedThreadID != thread::id();
205 if (!try_lock_shared())
208 SharedMutexBase::lock_shared();
#define JPH_SUPPRESS_WARNINGS_STD_BEGIN
Definition: Core.h:383
#define JPH_SUPPRESS_WARNINGS_STD_END
Definition: Core.h:395
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_IF_ENABLE_ASSERTS(...)
Definition: IssueReporting.h:35
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
shared_mutex SharedMutexBase
Definition: Mutex.h:113
mutex MutexBase
Definition: Mutex.h:112
#define JPH_PROFILE(...)
Definition: Profiler.h:268
void unlock()
Definition: Mutex.h:145
bool try_lock()
Definition: Mutex.h:124
void lock()
Definition: Mutex.h:135
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
void lock_shared()
Definition: Mutex.h:203
void unlock()
Definition: Mutex.h:189
void lock()
Definition: Mutex.h:179
bool try_lock()
Definition: Mutex.h:168