Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members  

RazorBack::Semaphore_ Class Reference

Semaphore_: wrapper class for POSIX thread semaphores. More...

#include <MTsync.hh>

List of all members.

Public Methods

 Semaphore_ ()
 Init to default.

 ~Semaphore_ ()
 dtor.

void reset ()
 reset(): wakes up all threads waiting on the semaphore and then sets the value to 0.

void increment (size_t Inc=1)
 increment(Inc): increases the semaphore value by Inc (1 by default).

void wait ()
 wait(): Waits until the semaphore value is 0.

void decrement_and_signal (size_t Dec=1)
 decrement_and_signal(Dec): decreases the semaphore value by Dec (1 by default) and signals a thread waiting on the semaphore when the value goes 0 (or below).

void decrement_and_broadcast (size_t Dec=1)
 decrement_and_broadcast(Dec): same as decrement_and_signal(Dec) but broadcasts to all threads waiting on the semaphore when Value goes to 0.


Private Methods

 Semaphore_ (const Semaphore_ &)
Semaphore_& operator= (const Semaphore_ &)

Private Attributes

int Value
pthread_cond_t Cond
 condition variable for Value=0.

pthread_mutex_t Mtx
 the associated mutex.


Detailed Description

Semaphore_: wrapper class for POSIX thread semaphores.

Definition at line 154 of file MTsync.hh.


Constructor & Destructor Documentation

RazorBack::Semaphore_::Semaphore_ ( ) [inline]
 

Init to default.

Definition at line 168 of file MTsync.hh.

RazorBack::Semaphore_::~Semaphore_ ( ) [inline]
 

dtor.

Definition at line 175 of file MTsync.hh.

RazorBack::Semaphore_::Semaphore_ ( const Semaphore_ & ) [private]
 


Member Function Documentation

void RazorBack::Semaphore_::reset ( )
 

reset(): wakes up all threads waiting on the semaphore and then sets the value to 0.

void RazorBack::Semaphore_::increment ( size_t Inc = 1 )
 

increment(Inc): increases the semaphore value by Inc (1 by default).

void RazorBack::Semaphore_::wait ( )
 

wait(): Waits until the semaphore value is 0.

void RazorBack::Semaphore_::decrement_and_signal ( size_t Dec = 1 )
 

decrement_and_signal(Dec): decreases the semaphore value by Dec (1 by default) and signals a thread waiting on the semaphore when the value goes 0 (or below).

void RazorBack::Semaphore_::decrement_and_broadcast ( size_t Dec = 1 )
 

decrement_and_broadcast(Dec): same as decrement_and_signal(Dec) but broadcasts to all threads waiting on the semaphore when Value goes to 0.

Semaphore_& RazorBack::Semaphore_::operator= ( const Semaphore_ & ) [private]
 


Member Data Documentation

int RazorBack::Semaphore_::Value [private]
 

Definition at line 159 of file MTsync.hh.

pthread_cond_t RazorBack::Semaphore_::Cond [private]
 

condition variable for Value=0.

Definition at line 160 of file MTsync.hh.

pthread_mutex_t RazorBack::Semaphore_::Mtx [private]
 

the associated mutex.

Definition at line 161 of file MTsync.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:35 2002 for The Razorback C++ Library: POSIX Thread Wrappers by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001