Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

Condition Class Reference

This class is used to control concurrent access. More...

#include <cxxtools/condition.h>

Inheritance diagram for Condition:

List of all members.

Public Member Functions

 Condition ()
 Default Constructor.
 ~Condition ()
 Destructor.
void wait (Mutex &mtx)
 Wait until condition becomes signalled.
void wait (MutexLock &m)
bool wait (Mutex &mtx, unsigned int ms)
 Wait until condition becomes signalled.
bool wait (MutexLock &m, unsigned int ms)
void signal ()
 Unblock a single blocked thread.
void broadcast ()
 Unblock all blocked threads.


Detailed Description

The Condition class is used to control concurrent access in a queued manner. The Condition class supports two types of signalling events, manual reset and automatic reset. Manual resets cause all blocked callers to be released. This can be understood as some kind of broadcast to signal all blocked callers at once. Manual resets are triggered by a call to signal(). Automatic resets cause only a single blocked caller to be released. So this can be seen as some kind of wait queue where only the topmost is signaled. Automatic resets are signaled by a call to broadcast().

Member Function Documentation

void wait ( Mutex mtx  ) 

Causes the caller to be suspended until the condition will be signaled. The given mutex will be unlocked before the caller is suspended.

Referenced by Pool< tntdb::Connection, tntdb::ConnectionPool::Connector >::get().

bool wait ( Mutex mtx,
unsigned int  ms 
)

Causes the caller to be suspended until the condition will be signaled. The given mutex will be unlocked before the caller is suspended. The suspension takes at maximum ms milliseconds. Returns true if successful, false if a timeout occurred.

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6