UCommon
ucommon::RWLock::reader Class Reference

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

#include <thread.h>

Public Member Functions

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

Static Public Member Functions

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

Detailed Description

Apply automatic scope based access locking to objects.

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

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

Definition at line 112 of file thread.h.

Constructor & Destructor Documentation

◆ reader() [1/2]

ucommon::RWLock::reader::reader ( )

Create an unitialized instance of guard.

Usually used with a guard = operator.

◆ reader() [2/2]

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

Construct a guard for a specific object.

Parameters
objectto guard.

Member Function Documentation

◆ lock()

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

Shared access to an arbitrary object.

This is based on the protect function of mutex.

Parameters
objectto share.
timeoutin milliseconds to wait for lock.
Returns
true if shared, false if timeout.

◆ operator=()

void ucommon::RWLock::reader::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 154 of file thread.h.

◆ set()

void ucommon::RWLock::reader::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: