StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::SharedMutex Class Reference

Non-recursive shared mutex. More...

#include <StormByte/safe/shared_mutex.hxx>

Public Member Functions

 SharedMutex ()
 Unlocked shared mutex.
 SharedMutex (const SharedMutex &)=delete
 SharedMutex (SharedMutex &&)=delete
 ~SharedMutex () noexcept
 Destroys the gate on Base's heap.
SharedMutex & operator= (const SharedMutex &)=delete
SharedMutex & operator= (SharedMutex &&)=delete
void lock ()
 Acquire exclusive ownership.
bool try_lock () noexcept
 Try to acquire exclusive ownership.
void unlock () noexcept
 Release exclusive ownership.
void lock_shared ()
 Acquire shared ownership.
bool try_lock_shared () noexcept
 Try to acquire shared ownership.
void unlock_shared () noexcept
 Release shared ownership.

Detailed Description

Non-recursive shared mutex.

The gate lives on Base's heap.

Not an alias of std::shared_mutex. Not copyable or movable. One exclusive owner, or several shared owners. unlock and unlock_shared without that ownership are undefined.

Constructor & Destructor Documentation

◆ SharedMutex() [1/3]

StormByte::Safe::SharedMutex::SharedMutex ( )

Unlocked shared mutex.

Exceptions
AllocationErrorThe gate cannot be allocated.

◆ SharedMutex() [2/3]

StormByte::Safe::SharedMutex::SharedMutex ( const SharedMutex & )
delete

◆ SharedMutex() [3/3]

StormByte::Safe::SharedMutex::SharedMutex ( SharedMutex && )
delete

◆ ~SharedMutex()

StormByte::Safe::SharedMutex::~SharedMutex ( )
noexcept

Destroys the gate on Base's heap.

Note
Every owner unlocks before destruction.

Member Function Documentation

◆ lock()

void StormByte::Safe::SharedMutex::lock ( )

Acquire exclusive ownership.

Exceptions
OperationErrorA foreign failure is translated.

◆ lock_shared()

void StormByte::Safe::SharedMutex::lock_shared ( )

Acquire shared ownership.

Exceptions
OperationErrorA foreign failure is translated.

◆ operator=() [1/2]

SharedMutex & StormByte::Safe::SharedMutex::operator= ( const SharedMutex & )
delete

◆ operator=() [2/2]

SharedMutex & StormByte::Safe::SharedMutex::operator= ( SharedMutex && )
delete

◆ try_lock()

bool StormByte::Safe::SharedMutex::try_lock ( )
noexcept

Try to acquire exclusive ownership.

Returns
Whether this thread now owns it exclusively.

◆ try_lock_shared()

bool StormByte::Safe::SharedMutex::try_lock_shared ( )
noexcept

Try to acquire shared ownership.

Returns
Whether this thread now owns it shared.

◆ unlock()

void StormByte::Safe::SharedMutex::unlock ( )
noexcept

Release exclusive ownership.

Precondition
The calling thread owns it exclusively.

◆ unlock_shared()

void StormByte::Safe::SharedMutex::unlock_shared ( )
noexcept

Release shared ownership.

Precondition
The calling thread owns it shared.

The documentation for this class was generated from the following file: