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

Non-recursive mutex. More...

#include <StormByte/safe/mutex.hxx>

Public Member Functions

 Mutex ()
 Unlocked mutex.
 Mutex (const Mutex &)=delete
 Mutex (Mutex &&)=delete
 ~Mutex () noexcept
 Destroys the gate on Base's heap.
Mutex & operator= (const Mutex &)=delete
Mutex & operator= (Mutex &&)=delete
void lock ()
 Acquire the mutex.
bool try_lock () noexcept
 Try to acquire the mutex.
void unlock () noexcept
 Release the mutex.

Friends

class ConditionVariable

Detailed Description

Non-recursive mutex.

The gate lives on Base's heap.

Not an alias of std::mutex. Not copyable or movable. unlock without ownership is undefined.

Constructor & Destructor Documentation

◆ Mutex() [1/3]

StormByte::Safe::Mutex::Mutex ( )

Unlocked mutex.

Exceptions
AllocationErrorThe gate cannot be allocated.

◆ Mutex() [2/3]

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

◆ Mutex() [3/3]

StormByte::Safe::Mutex::Mutex ( Mutex && )
delete

◆ ~Mutex()

StormByte::Safe::Mutex::~Mutex ( )
noexcept

Destroys the gate on Base's heap.

Note
The owner unlocks before destruction.

Member Function Documentation

◆ lock()

void StormByte::Safe::Mutex::lock ( )

Acquire the mutex.

Exceptions
OperationErrorA foreign failure is translated.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ try_lock()

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

Try to acquire the mutex.

Returns
Whether this thread now owns it.

◆ unlock()

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

Release the mutex.

Precondition
The calling thread owns it.

◆ ConditionVariable

friend class ConditionVariable
friend

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