UCommon
ucommon::RWLock::writer Class Reference

Apply automatic scope based exclusive locking to objects. More...

#include <thread.h>

Public Member Functions

void operator= (const void *pointer)
 Set guard to read lock a new object.
 
void release (void)
 Prematurely release a guard.
 
void set (const void *object)
 Set guard to mutex lock a new object.
 
 writer ()
 Create an unitialized instance of guard.
 
 writer (const void *object)
 Construct a guard for a specific object.
 
 ~writer ()
 Release mutex when guard falls out of scope.
 

Static Public Member Functions

static bool lock (const void *object, timeout_t timeout=Timer::inf)
 Write protect access to an arbitrary object.
 

Detailed Description

Apply automatic scope based exclusive locking to objects.

The rwlock is located from the rwlock pool rather than contained in the target object, and the write lock is released when the guard object falls out of scope. This is essentially an automation mechanism for mutex::writer.

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

Definition at line 175 of file thread.h.

Constructor & Destructor Documentation

◆ writer() [1/2]

ucommon::RWLock::writer::writer ( )

Create an unitialized instance of guard.

Usually used with a guard = operator.

◆ writer() [2/2]

ucommon::RWLock::writer::writer ( const void * object)

Construct a guard for a specific object.

Parameters
objectto guard.

Member Function Documentation

◆ lock()

static bool ucommon::RWLock::writer::lock ( const void * object,
timeout_t timeout = Timer::inf )
static

Write protect access to an arbitrary object.

This is like the protect function of mutex.

Parameters
objectto protect.
timeoutin milliseconds to wait for lock.
Returns
true if locked, false if timeout.

◆ operator=()

void ucommon::RWLock::writer::operator= ( const void * pointer)
inline

Set guard to read lock a new object.

If a lock is currently held, it is released.

Parameters
pointerto object to guard.

Definition at line 217 of file thread.h.

◆ set()

void ucommon::RWLock::writer::set ( const void * object)

Set guard to mutex lock a new object.

If a lock is currently held, it is released.

Parameters
objectto guard.

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