|
PWLib 1.10.10
|
#include <psync.h>
Public Member Functions | |
| PWaitAndSignal (const PSync &sem, BOOL wait=TRUE) | |
| ~PWaitAndSignal () | |
Protected Attributes | |
| PSync & | sync |
This class waits for the semaphore on construction and automatically signals the semaphore on destruction. Any descendent of PSemaphore may be used.
This is very usefull for constructs such as: {verbatim} void func() { PWaitAndSignal mutexWait(myMutex); if (condition) return; do_something(); if (other_condition) return; do_something_else(); } {verbatim}
| PWaitAndSignal::PWaitAndSignal | ( | const PSync & | sem, |
| BOOL | wait = TRUE |
||
| ) | [inline] |
Create the semaphore wait instance. This will wait on the specified semaphore using the #Wait()# function before returning.
| sem | Semaphore descendent to wait/signal. |
| wait | Wait for semaphore before returning. |
References sync, and PSync::Wait().
| PWaitAndSignal::~PWaitAndSignal | ( | ) | [inline] |
Signal the semaphore. This will execute the Signal() function on the semaphore that was used in the construction of this instance.
References PSync::Signal(), and sync.
PSync& PWaitAndSignal::sync [protected] |
Referenced by PWaitAndSignal(), and ~PWaitAndSignal().
1.7.4