Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::Mutex Class Reference

Core class that represents a binary semaphore, a mutex. More...

Public Member Functions

 Mutex ()
 Constructs a Mutex object by default.
 
 Mutex (const Mutex &)=delete
 
 Mutex (Mutex &&) noexcept=default
 
 ~Mutex ()
 Destructs the object.
 
void Lock ()
 Locks the mutex. More...
 
bool TryLock ()
 Tries to lock the mutex. More...
 
void Unlock ()
 Unlocks the mutex. More...
 
Mutexoperator= (const Mutex &)=delete
 
Mutexoperator= (Mutex &&) noexcept=default
 

Friends

class ConditionVariable
 

Detailed Description

Core class that represents a binary semaphore, a mutex.

Remarks
The mutex is recursive, it means that a thread who owns the mutex can call the same function which needs the same mutex

Member Function Documentation

◆ Lock()

void Nz::Mutex::Lock ( )

Locks the mutex.

If another thread has already locked the mutex, a call to lock will block execution until the lock is acquired. A thread may call lock on a recursive mutex repeatedly. Ownership will only be released after the thread makes a matching number of calls to unlock

◆ TryLock()

bool Nz::Mutex::TryLock ( )

Tries to lock the mutex.

Returns
true if the lock was acquired successfully

◆ Unlock()

void Nz::Mutex::Unlock ( )

Unlocks the mutex.

Unlocks the mutex if its level of ownership is 1 (there was exactly one more call to Lock() than there were calls to Unlock() made by this thread), reduces the level of ownership by 1 otherwise


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