#include <mutex.hpp>
Public Member Functions | |
mutex () | |
Initializes this mutex. | |
~mutex () throw () | |
Closes the mutex. | |
mutex & | lock () |
Locks this mutex. | |
void | unlock () |
Unlocks this mutex. | |
mutex & | operator= (mutex const &) |
Copying a mutex is a no-op. | |
mutex (mutex const &) | |
This ctor ignores its argument and behaves identically to the default ctor. |
Notes about the underlying mutex implementation(s):
To simulate a global mutex, create a shared instance of this type, e.g., via a myApp::getGlobalMutex() function.
Definition at line 22 of file mutex.hpp.
s11n::mutex::mutex | ( | ) |
Initializes this mutex.
s11n::mutex::~mutex | ( | ) | throw () |
Closes the mutex.
s11n::mutex::mutex | ( | mutex const & | ) |
This ctor ignores its argument and behaves identically to the default ctor.
See operator=().
mutex& s11n::mutex::lock | ( | ) |
Locks this mutex.
Trying to lock it a second (or subsequent) time will cause this function to wait until the previous lock(s) is (are) released.
Recursive locks are not supported, which means that if you call lock() twice on a mutex without an intervening unlock(), you will deadlock. Code using this mutex must be careful to avoid this case (see the mutex_sentry class, which is one solution).
Returns a reference to this object mainly to allow this call to be used in ctor member initialization lists, but maybe that will have some other use eventually.
void s11n::mutex::unlock | ( | ) |
Unlocks this mutex.