Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
P6R::p6ICondvar Interface Referenceabstract

#include <p6lock.h>

Inherits P6R::p6ICom.

Public Member Functions

virtual P6INT32 addref (void)=0
 
virtual P6R::P6ERR initialize (p6ILock *pLock)=0
 
virtual P6R::P6ERR notify (void)=0
 
virtual P6R::P6ERR notifyAll (void)=0
 
virtual P6R::P6ERR queryInterface (const P6R::P6IID &iid, P6VOID **ppIface)=0
 
virtual P6INT32 release (void)=0
 
virtual P6R::P6ERR wait (void)=0
 
virtual P6R::P6ERR waitTimed (P6INTERVAL tTimeout)=0
 

Detailed Description

Conditional variable.

To avoid a busy wait, condition variables are used to block threads until a specified condition is true.

Condition variables must always be used with an assosiated lock (P6R::p6ILock). The following code example demonstrates the proper use of a condition variable.

* mutex.lock();
* while(false == condition)
* condvar.wait();
* mutex.unlock();
*

Notice that the wait MUST be called while holding the lock and MUST be called in a while loop testing the condition. This is because on some operating systems, the wait may be terminted prematurely (not the result of a notify() or notify all or the timeout period expiring). This is known as the "spurious wakeup problem" and the while loop works around the issue by ensure that condition was met before continuing.

Definition at line 198 of file p6lock.h.


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