ADTF  3.18.2
shared_mutex

A shared_mutex class as a workaround for std::shared_timed_mutex. More...

Public Member Functions

 shared_mutex ()
 CTOR - creates the mutex in an unlocked state.
 
 ~shared_mutex ()
 DTOR - does not call unlock!
 
void lock ()
 Lock the mutex, blocks if the mutex is not available.
 
bool try_lock ()
 Try to lock the mutex. More...
 
void unlock ()
 Unlock the mutex.
 
void lock_shared ()
 Lock the mutex for shared ownership, blocks if the mutex is not available.
 
bool try_lock_shared ()
 Try to lock the mutex for shared ownership. More...
 
void unlock_shared ()
 Unlock the mutex (shared ownership)
 

Private Member Functions

 shared_mutex (const shared_mutex &)
 
shared_mutexoperator= (const shared_mutex &)
 

Private Attributes

std::unique_ptr< impl > p
 

Detailed Description

A shared_mutex class as a workaround for std::shared_timed_mutex.

See also
https://stackoverflow.com/a/42302130

Definition at line 26 of file shared_mutex.h.

Member Function Documentation

◆ try_lock()

bool try_lock ( )

Try to lock the mutex.

Returns
true if successfully locked, false otherwise.

◆ try_lock_shared()

bool try_lock_shared ( )

Try to lock the mutex for shared ownership.

Returns
true if successfully locked, false otherwise