Public Types | Public Member Functions | Protected Attributes

base::SharedLock Class Reference

Shared lock, allows multiple readers but only one writer at a time. More...

#include <libppbase/base/SharedLock.h>

Inheritance diagram for base::SharedLock:
base::Mutex

List of all members.

Public Types

enum  { UNLOCKED = 0, READ, WRITE, DYNAMIC }
 

lock modes, states and priorities

More...

Public Member Functions

 SharedLock (size_t priority=DYNAMIC)
 Constructor.
 ~SharedLock ()
 Destructor.
void lock (size_t mode=READ)
 Locks this lock.
void unlock ()
 Unlocks this lock.

Protected Attributes

size_t _priority
 priority setting (READ, WRITE or DYNAMIC)
Condition_rcond
 reader condition variable
size_t _reader
 number of readers in case of _state == READ
size_t _reader_waiting
 number of readers waiting
size_t _state
 current lock state (UNLOCKED, READ or WRITE)
Condition_wcond
 writer condition variable
size_t _writer_waiting
 number of writers waiting

Detailed Description

Shared lock, allows multiple readers but only one writer at a time.

Author:
Christoph Schwarz
Version:
$Id: SharedLock.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Enumeration Documentation

anonymous enum

lock modes, states and priorities

Enumerator:
UNLOCKED 

the lock is unlocked

READ 

the lock is owned by readers, a reader wants to lock it, or read priority

WRITE 

the lock is owned by writers, a writer wants to lock it, or write priority

DYNAMIC 

dynamic priority


Constructor & Destructor Documentation

base::SharedLock::SharedLock ( size_t  priority = DYNAMIC  ) 

Constructor.

Parameters:
priority The access mode that has priority

Member Function Documentation

void base::SharedLock::lock ( size_t  mode = READ  ) 

Locks this lock.

Parameters:
mode Lock mode, READ or WRITE

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