Class named_mutex#

Class Documentation#

class named_mutex#

Named mutex allowing interprocess synchronization. This mutex class can be used with the standard C++ library.

Public Functions

named_mutex(const char *szName = nullptr) noexcept#

Named mutex constructor. Opens or creates a named mutex. This mutex is unlocked.

Parameters:

szName[in] Pointer to the zero terminated name of the mutex. Can be null to automatically generate a name.

named_mutex(const named_mutex&) = delete#

Copy constructor is deleted.

named_mutex(named_mutex &&rmtx) noexcept#

Move constructor.

Parameters:

rmtx[in] Reference to the mutex to move from.

~named_mutex()#

Destructor.

named_mutex &operator=(const named_mutex&) = delete#

Assignment operator is deleted.

Returns:

Reference to this class.

named_mutex &operator=(named_mutex &&rmtx) noexcept#

Move operator.

Parameters:

rmtx[in] Reference to the mutex to move from.

Returns:

Reference to this class.

void lock()#

Locks the mutex, blocks if the mutex is not available.

bool try_lock()#

Tries to lock the mutex, returns if the mutex is not available.

Returns:

Returns ‘true’ when the lock was successful; ‘false’ when not.

void unlock()#

Unlocks the mutex.

const std::string &name() const#

Return the mutex name.

Returns:

Reference to the name of the mutex.

native_handle_type native_handle()#

Return the underlying implementation-defined native handle object.

Returns:

Handle to the mutex.