Tkrzw
Public Member Functions | List of all members
tkrzw::SpinSharedMutex Class Referencefinal

Spin lock shared mutex. More...

#include <tkrzw_thread_util.h>

Public Member Functions

 SpinSharedMutex ()
 Constructor. More...
 
 SpinSharedMutex (const SpinSharedMutex &rhs)=delete
 Copy and assignment are disabled. More...
 
SpinSharedMutexoperator= (const SpinSharedMutex &rhs)=delete
 
void lock ()
 Gets exclusive ownership of the lock. More...
 
bool try_lock ()
 Tries to get exclusive ownership of the lock. More...
 
void unlock ()
 Releases exclusive ownership of the lock. More...
 
void lock_shared ()
 Gets shared ownership of the lock. More...
 
bool try_lock_shared ()
 Tries to get shared ownership of the lock. More...
 
void unlock_shared ()
 Releases shared ownership of the lock. More...
 
bool try_upgrade (bool wait=false)
 Tries to upgrade shared ownership to exclusive ownership. More...
 
void downgrade ()
 Downgrades exclusive ownership.to shared ownership. More...
 

Detailed Description

Spin lock shared mutex.

Constructor & Destructor Documentation

◆ SpinSharedMutex() [1/2]

tkrzw::SpinSharedMutex::SpinSharedMutex ( )

Constructor.

◆ SpinSharedMutex() [2/2]

tkrzw::SpinSharedMutex::SpinSharedMutex ( const SpinSharedMutex rhs)
explicitdelete

Copy and assignment are disabled.

Member Function Documentation

◆ lock()

void tkrzw::SpinSharedMutex::lock ( )

Gets exclusive ownership of the lock.

Precondition: The thread doesn't have any ownership.

◆ try_lock()

bool tkrzw::SpinSharedMutex::try_lock ( )

Tries to get exclusive ownership of the lock.

Returns
True if successful or false on failure.

Precondition: The thread doesn't have any ownership.

◆ unlock()

void tkrzw::SpinSharedMutex::unlock ( )

Releases exclusive ownership of the lock.

Precondition: The thread has the exclusive ownership.

◆ lock_shared()

void tkrzw::SpinSharedMutex::lock_shared ( )

Gets shared ownership of the lock.

Precondition: The thread doesn't have any ownership.

◆ try_lock_shared()

bool tkrzw::SpinSharedMutex::try_lock_shared ( )

Tries to get shared ownership of the lock.

Returns
True if successful or false on failure.

Precondition: The thread doesn't have any ownership.

◆ unlock_shared()

void tkrzw::SpinSharedMutex::unlock_shared ( )

Releases shared ownership of the lock.

Precondition: The thread has the shared ownership.

◆ try_upgrade()

bool tkrzw::SpinSharedMutex::try_upgrade ( bool  wait = false)

Tries to upgrade shared ownership to exclusive ownership.

Parameters
waitIf true, waits while there's possibility to get exclusive ownership.
Returns
True if successful or false on failure.

Precondition: The thread has the shared ownership.

◆ downgrade()

void tkrzw::SpinSharedMutex::downgrade ( )

Downgrades exclusive ownership.to shared ownership.

Precondition: The thread has the exclusive ownership.