Honeycomb  0.1
Component-Model Framework
Classes | Public Types | Public Member Functions | List of all members
honey::SharedMutex Class Reference

A thread lock for shared data where there may be many readers and one writer. More...

#include <SharedMutex.h>

Public Types

typedef UniqueLock< SharedMutexScoped
 
typedef SharedLock< SharedMutexSharedScoped
 

Public Member Functions

 SharedMutex ()
 
 SharedMutex (const SharedMutex &)
 Can't copy, silently inits to default. More...
 
 ~SharedMutex ()
 
SharedMutexoperator= (const SharedMutex &)
 Can't copy, silently does nothing. More...
 
void lock ()
 Acquire the unique writer lock. Thread suspends until lock is available and all readers release the shared lock. More...
 
void unlock ()
 Release the unique writer lock. More...
 
bool tryLock ()
 Attempt to acquire the unique writer lock, returns immediately. Returns true if the lock was acquired, false otherwise. More...
 
bool tryLock (MonoClock::Duration time)
 Attempt to acquire the unique writer lock for an amount of time. Returns true if the lock was acquired, false if timed out. More...
 
bool tryLock (MonoClock::TimePoint time)
 Attempt to acquire the unique writer lock until a certain time. Returns true if the lock was acquired, false if timed out. More...
 
void lockShared ()
 Acquire the shared reader lock. Thread suspends until writer lock has been released. More...
 
void unlockShared ()
 Release the shared reader lock. More...
 
bool tryLockShared ()
 Attempt to acquire the shared reader lock, returns immediately. Returns true if the lock was acquired, false otherwise. More...
 
bool tryLockShared (MonoClock::Duration time)
 Attempt to acquire the shared reader lock for an amount of time. Returns true if the lock was acquired, false if timed out. More...
 
bool tryLockShared (MonoClock::TimePoint time)
 Attempt to acquire the shared reader lock until a certain time. Returns true if the lock was acquired, false if timed out. More...
 
void unlockAndLockShared ()
 Atomically unlock unique writer lock and acquire shared reader lock without blocking. More...
 

Detailed Description

A thread lock for shared data where there may be many readers and one writer.

A thread acquiring a writer lock will suspend execution while there are readers.
The lock is recursive: one thread can acquire the lock multiple times, which must be followed by the same number of unlocks.
This class uses atomics, so locking without contention is faster than a platform Mutex.

Member Typedef Documentation

Constructor & Destructor Documentation

honey::SharedMutex::SharedMutex ( )
inline
honey::SharedMutex::SharedMutex ( const SharedMutex )
inline

Can't copy, silently inits to default.

honey::SharedMutex::~SharedMutex ( )
inline

Member Function Documentation

void honey::SharedMutex::lock ( )

Acquire the unique writer lock. Thread suspends until lock is available and all readers release the shared lock.

void honey::SharedMutex::lockShared ( )

Acquire the shared reader lock. Thread suspends until writer lock has been released.

SharedMutex& honey::SharedMutex::operator= ( const SharedMutex )
inline

Can't copy, silently does nothing.

bool honey::SharedMutex::tryLock ( )

Attempt to acquire the unique writer lock, returns immediately. Returns true if the lock was acquired, false otherwise.

bool honey::SharedMutex::tryLock ( MonoClock::Duration  time)
inline

Attempt to acquire the unique writer lock for an amount of time. Returns true if the lock was acquired, false if timed out.

bool honey::SharedMutex::tryLock ( MonoClock::TimePoint  time)

Attempt to acquire the unique writer lock until a certain time. Returns true if the lock was acquired, false if timed out.

bool honey::SharedMutex::tryLockShared ( )

Attempt to acquire the shared reader lock, returns immediately. Returns true if the lock was acquired, false otherwise.

bool honey::SharedMutex::tryLockShared ( MonoClock::Duration  time)
inline

Attempt to acquire the shared reader lock for an amount of time. Returns true if the lock was acquired, false if timed out.

bool honey::SharedMutex::tryLockShared ( MonoClock::TimePoint  time)

Attempt to acquire the shared reader lock until a certain time. Returns true if the lock was acquired, false if timed out.

void honey::SharedMutex::unlock ( )

Release the unique writer lock.

void honey::SharedMutex::unlockAndLockShared ( )

Atomically unlock unique writer lock and acquire shared reader lock without blocking.

void honey::SharedMutex::unlockShared ( )

Release the shared reader lock.


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