dbp::event Class Reference

Condition variable lock (event). More...

#include <event.h>

Inherits dbp::event_int.

Collaboration diagram for dbp::event:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 event (mutex &m)
 Constructor.
virtual ~event ()
 Destructor.
virtual void wait ()
 Wait for event raising.
virtual void raise ()
 Raise the event.

Detailed Description

Condition variable lock (event).

A condition variable is a synchronization object that allows threads to suspend execution and relinquish the processors until some predicate on shared data is satisfied. The basic operations on conditions are: signal the condition (when the predicate becomes true), and wait for the condition, suspending the thread execution until another thread signals the condition.

A condition variable must always be associated with a mutex, to avoid the race condition where a thread prepares to wait on a condition variable and another thread signals the condition just before the first thread actually waits on it.


Constructor & Destructor Documentation

dbp::event::event ( mutex m  ) 

Constructor.

Initializes the event with the provided mutex object.

Parameters:
m the mutex to associate with.

Member Function Documentation

virtual void dbp::event::raise (  )  [virtual]

Raise the event.

Restarts all the threads that are waiting on this condition variable. Nothing happens if no threads are waiting on this one.

virtual void dbp::event::wait (  )  [virtual]

Wait for event raising.

Atomically unlocks the associated mutex and waits for the condition variable to be raised. The thread execution is suspended and does not consume any CPU time until the condition variable is raised. The mutex must be locked by the calling thread on entrance to wait(). Before returning to the calling thread, wait() re-acquires mutex.


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

 
Support This Project
SourceForge.net Logo