carb::thread::recursive_mutex
Defined in carb/thread/Mutex.h
- 
class recursive_mutex : protected detail::BaseMutex<true>
- A Carbonite implementation of std::recursive_mutex. - Note - Windows: - std::recursive_mutexuses- SRWLOCKfor Win 7+,- CONDITION_VARIABLEfor Vista and the massive- CRITICAL_SECTIONfor pre-Vista. Due to this, the- std::recursive_mutexclass is about 80 bytes. Since Carbonite supports Windows 10 and later,- SRWLOCKis used exclusively. This implementation is 16 bytes. This version that uses- SRWLOCKis significantly faster on Windows than the portable implementation used for the linux version.- Note - Linux: - sizeof(std::recursive_mutex)is 40 bytes on GLIBC 2.27, which is based on the size of- pthread_mutex_t. The Carbonite implementation of recursive_mutex is 24 bytes and at least as performant as- std::recursive_mutexin the contended case.- Public Functions - 
recursive_mutex() noexcept = default
- Constructor. - Note - Unlike - std::recursive_mutex, this implementation can be declared- constexpr.
 - 
~recursive_mutex() = default
- Destructor. - Warning - std::terminate()is called if recursive_mutex is locked by a thread.
 - 
inline void lock()
- Locks the recursive_mutex, blocking until it becomes available. - The calling thread must call unlock() at a later time to release the lock. There must be symmetrical calls to unlock() for each call to lock() or successful call to try_lock(). 
 - 
inline bool try_lock()
- Attempts to immediately lock the recursive_mutex. - Returns
- trueif the recursive_mutex was available and the lock was taken by the calling thread (unlock() must be called from the calling thread at a later time to release the lock);- falseif the recursive_mutex could not be locked by the calling thread. If the lock was already held by the calling thread,- trueis always returned.
 
 - 
inline void unlock()
- Unlocks the recursive_mutex. - Warning - std::terminate()is called if the calling thread does not own the recursive_mutex.
 - 
inline bool is_current_thread_owner() const noexcept
- Checks if the current thread owns the mutex. - Note - This is a non-standard Carbonite extension. - Returns
- trueif the current thread owns the mutex;- falseotherwise.
 
 
- 
recursive_mutex() noexcept = default