UCommon
|
Guard class to apply scope based mutex locking to objects. More...
#include <thread.h>
Inherited by ucommon::autoprotect< T >.
Public Member Functions | |
AutoProtect (const void *object) | |
Construct a guard for a specific object. More... | |
operator bool () const | |
bool | operator! () const |
~AutoProtect () | |
Release mutex when guard falls out of scope. | |
Protected Member Functions | |
AutoProtect () | |
Create an unitialized instance of guard. More... | |
void | release (void) |
Prematurely release a guard. | |
void | set (const void *object) |
Set guard to mutex lock a new object. More... | |
Protected Attributes | |
const void * | object |
Guard class to apply scope based mutex locking to objects.
The mutex is located from the mutex pool rather than contained in the target object, and the lock is released when the guard object falls out of scope. This is essentially an automation mechanism for mutex::protect.
|
protected |
Create an unitialized instance of guard.
Usually used with a guard = operator.
ucommon::AutoProtect::AutoProtect | ( | const void * | object | ) |
Construct a guard for a specific object.
object | to guard. |
|
protected |
Set guard to mutex lock a new object.
If a lock is currently held, it is released.
object | to guard. |