Public Member Functions | Protected Member Functions | Protected Attributes

base::Condition Class Reference

A condition variable. More...

#include <libppbase/base/Condition.h>

Inheritance diagram for base::Condition:
base::ThreadList base::WorkPile< T >

List of all members.

Public Member Functions

 Condition (Mutex *mutex=NULL, bool own=false)
 Constructor.
 ~Condition ()
 Destructor.
void lock ()
 Locks the associated mutex.
void signal (bool broadcast=false)
 Signals the condition.
void unlock ()
 Unlocks the associated mutex.
bool wait (int timeout=0, bool dolock=false)
 Waits for the condition.

Protected Member Functions

 DISALLOW_COPY_CONSTRUCTOR_AND_ASSIGNMENT (Condition)
 condition objects may not be duplicated

Protected Attributes

pthread_cond_t _cond
 the pthread condition variable
Mutex_mutex
 associated mutex
bool _own
 flag: owns mutex

Detailed Description

A condition variable.

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

Member Function Documentation

void base::Condition::signal ( bool  broadcast = false  ) 

Signals the condition.

Parameters:
broadcast flag: wake up all threads waiting on this condition

Referenced by base::WorkPile< Socket * >::dequeue(), and base::WorkPile< Socket * >::enqueue().

bool base::Condition::wait ( int  timeout = 0,
bool  dolock = false 
)

Waits for the condition.

Parameters:
timeout timeout in seconds, <=0 means infinite
dolock flag: lock the mutex
Returns:
false means timeout

Referenced by base::WorkPile< Socket * >::dequeue(), and base::WorkPile< Socket * >::enqueue().


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