UCommon
ucommon::AutoProtect Class Reference

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.
 
 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.
 
void release (void)
 Prematurely release a guard.
 
void set (const void *object)
 Set guard to mutex lock a new object.
 

Protected Attributes

const void * object
 

Detailed Description

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.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 556 of file thread.h.

Constructor & Destructor Documentation

◆ AutoProtect() [1/2]

ucommon::AutoProtect::AutoProtect ( )
protected

Create an unitialized instance of guard.

Usually used with a guard = operator.

◆ AutoProtect() [2/2]

ucommon::AutoProtect::AutoProtect ( const void * object)

Construct a guard for a specific object.

Parameters
objectto guard.

Member Function Documentation

◆ operator bool()

ucommon::AutoProtect::operator bool ( ) const
inline

Definition at line 595 of file thread.h.

◆ operator!()

bool ucommon::AutoProtect::operator! ( ) const
inline

Definition at line 599 of file thread.h.

◆ set()

void ucommon::AutoProtect::set ( const void * object)
protected

Set guard to mutex lock a new object.

If a lock is currently held, it is released.

Parameters
objectto guard.

Field Documentation

◆ object

const void* ucommon::AutoProtect::object
protected

Definition at line 563 of file thread.h.


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