libpsynth 0.2.1
Public Types | Public Member Functions
psynth::rwlock Class Reference

A lock that implements mutual exclusion for writers but allows multiple readers. More...

#include <mutex.hpp>

List of all members.

Public Types

enum  type { DEFAULT }

Public Member Functions

 rwlock (int type=DEFAULT)
 Constructor.
 ~rwlock ()
 Destructor.
void read_lock () const
 Locks as a reader.
void write_lock () const
 Locks as a writer.
bool try_read_lock () const
 Tries to do a readLock.
bool try_write_lock ()
 Tries to do a writeLock.
void unlock () const
 Unlocks the RWLock.

Detailed Description

A lock that implements mutual exclusion for writers but allows multiple readers.

See also:
Mutex

Member Enumeration Documentation

Enumerator:
DEFAULT 

Constructor & Destructor Documentation

psynth::rwlock::rwlock ( int  type = DEFAULT) [inline]

Constructor.

Parameters:
typeThe type of lock, defaults to DEFAULT.
psynth::rwlock::~rwlock ( ) [inline]

Destructor.


Member Function Documentation

void psynth::rwlock::read_lock ( ) const [inline]

Locks as a reader.

It will block it is currently locked by a writer or if any writer is willing to lock it when using PREFER_WRITER type.

bool psynth::rwlock::try_read_lock ( ) const [inline]

Tries to do a readLock.

Returns:
true if we could lock the RWLock and false if it was already locked.
bool psynth::rwlock::try_write_lock ( ) [inline]

Tries to do a writeLock.

Returns:
true if we could lock the RWLock and false if it was already locked.
void psynth::rwlock::unlock ( ) const [inline]

Unlocks the RWLock.

void psynth::rwlock::write_lock ( ) const [inline]

Locks as a writer.

It will block if the lock is locked is already locked by anyone, reader or writer.


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