Cbeam
|
Provides a cross-platform interface for recursive named mutexes, enabling interprocess synchronization. More...
#include <named_recursive_mutex.hpp>
Public Member Functions | |
named_recursive_mutex (const std::string &name) | |
Constructs a named_recursive_mutex with a specified name. | |
virtual | ~named_recursive_mutex () noexcept |
Destructor for named_recursive_mutex. | |
void | lock () const |
Acquires the mutex lock. | |
void | unlock () const |
Releases the mutex lock. | |
named_recursive_mutex (const named_recursive_mutex &)=delete | |
named_recursive_mutex & | operator= (const named_recursive_mutex &)=delete |
named_recursive_mutex (named_recursive_mutex &&)=delete | |
named_recursive_mutex & | operator= (named_recursive_mutex &&)=delete |
Provides a cross-platform interface for recursive named mutexes, enabling interprocess synchronization.
On Linux and Mac OS X, this class mimics the functionality of boost::interprocess::named_recursive_mutex. On Windows, it utilizes the native Windows API for named mutexes, which differs from Linux and Mac OS X in:
|
inline |
Constructs a named_recursive_mutex with a specified name.
Initializes the mutex based on the operating system. On Windows, it creates a native mutex using CreateMutexA. On Unix-based systems, it sets up a shared memory and initializes a pthread mutex.
cbeam::error::system_error | Thrown if mutex creation or initialization fails. |
name | The unique name of the mutex for interprocess identification. |
|
inlinevirtualnoexcept |
Destructor for named_recursive_mutex.
Cleans up resources allocated for the mutex. On Windows, it closes the handle to the mutex. On Unix-based systems, it destroys the pthread mutex and unmaps the shared memory.
|
delete |
|
delete |
|
inline |
Acquires the mutex lock.
On Windows, it uses WaitForSingleObject to wait for the mutex. On Unix-based systems, it locks the pthread mutex.
cbeam::error::system_error | Thrown if locking the mutex fails. |
|
delete |
|
delete |
|
inline |
Releases the mutex lock.
On Windows, it releases the mutex using ReleaseMutex. On Unix-based systems, it unlocks the pthread mutex.
cbeam::error::system_error | Thrown if unlocking the mutex fails. |