class PWaitAndSignal

This class waits for the semaphore on construction and automatically signals the semaphore on destruction.

Public Methods

[more] PWaitAndSignal ( PSemaphore & sem, BOOL wait = TRUE )
Create the semaphore wait instance.
[more] ~PWaitAndSignal ()
Signal the semaphore.


Documentation

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:

    void func()
    {
      PWaitAndSignal mutexWait(myMutex);
      if (condition)
        return;
      do_something();
      if (other_condition)
        return;
      do_something_else();
    }
o PWaitAndSignal( PSemaphore & sem, BOOL wait = TRUE )
Create the semaphore wait instance. This will wait on the specified semaphore using the Wait() function before returning.
Parameters:
sem - Semaphore descendent to wait/signal.
wait - Wait for semaphore before returning.

o ~PWaitAndSignal()
Signal the semaphore. This will execute the Signal() function on the semaphore that was used in the construction of this instance.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.