Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | List of all members
Mezzanine::Threading::Mutex Class Reference

A cross-platform abstraction of the OS's mutex. More...

#include <mutex.h>

Public Member Functions

 Mutex ()
 Constructor, creates an unlocked mutex.
 
 ~Mutex ()
 Destructor.
 
void Lock ()
 Lock the mutex. More...
 
void lock ()
 Simply calls Lock() for compatibility with lock_guard and other more standard mutexes.
 
bool TryLock ()
 Try to lock the mutex. More...
 
void Unlock ()
 Unlock the mutex. More...
 
void unlock ()
 Simply calls Unlock() for compatibility with lock_guard and other more standard mutexes.
 

Detailed Description

A cross-platform abstraction of the OS's mutex.

Use this for potentially long delays, like making multiple system calls. This is likely slower than a spinlock, but it informs the OS of delay and could allow another thread to be scheduled, making use of the time the current thread would otherwise spin.

Definition at line 97 of file mutex.h.

Member Function Documentation

void Mezzanine::Threading::Mutex::Lock ( )

Lock the mutex.

The method will block the calling thread until a lock on the mutex can be obtained. The mutex remains locked until unlock() is called.

See also
lock_guard

Definition at line 78 of file mutex.cpp.

bool Mezzanine::Threading::Mutex::TryLock ( )

Try to lock the mutex.

The method will try to lock the mutex. If it fails, the function will return immediately (non-blocking).

Returns
true if the lock was acquired, or false if the lock could not be acquired.

Definition at line 89 of file mutex.cpp.

void Mezzanine::Threading::Mutex::Unlock ( )

Unlock the mutex.

If any threads are waiting for the lock on this mutex, one of them will be unblocked.

Definition at line 104 of file mutex.cpp.


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