ucommon
Public Member Functions | Protected Attributes
ucommon::auto_protect Class Reference

A mutex locked object smart pointer helper class. More...

#include <thread.h>

Inheritance diagram for ucommon::auto_protect:
Inheritance graph
[legend]

Public Member Functions

 auto_protect (const void *object)
 Construct a protected pointer referencing an existing object. More...
 
 operator bool () const
 Test if the pointer is referencing an object. More...
 
bool operator! () const
 Test if the pointer is not set. More...
 
void operator= (const void *object)
 Set our pointer to a specific object. More...
 
void release (void)
 Manually release the pointer. More...
 
 ~auto_protect ()
 Delete protected pointer. More...
 

Protected Attributes

const void * object
 

Detailed Description

A mutex locked object smart pointer helper class.

This is particularly useful in referencing objects which will be protected by the mutex protect function. When the pointer falls out of scope, the protecting mutex is also released. This is meant to be used by the typed mutex_pointer template.

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

Definition at line 1066 of file thread.h.

Constructor & Destructor Documentation

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

Construct a protected pointer referencing an existing object.

Parameters
objectwe point to.
ucommon::auto_protect::~auto_protect ( )

Delete protected pointer.

When it falls out of scope the associated mutex is released.

Member Function Documentation

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

Test if the pointer is referencing an object.

Returns
true if the pointer is currently referencing an object.

Definition at line 1106 of file thread.h.

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

Test if the pointer is not set.

Returns
true if the pointer is not referencing anything.

Definition at line 1099 of file thread.h.

void ucommon::auto_protect::operator= ( const void *  object)

Set our pointer to a specific object.

If the pointer currently references another object, the associated mutex is released. The pointer references our new object and that new object is locked.

Parameters
objectto assign to.
void ucommon::auto_protect::release ( void  )

Manually release the pointer.

This releases the mutex.


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