PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PReadWaitAndSignal Class Reference

This class starts a read operation for the PReadWriteMutex on construction and automatically ends the read operation on destruction. More...

#include <syncthrd.h>

Collaboration diagram for PReadWaitAndSignal:

Public Member Functions

 PReadWaitAndSignal (const PReadWriteMutex &rw, PBoolean start=true)
 Create the PReadWaitAndSignal wait instance. More...
 
 ~PReadWaitAndSignal ()
 End read operation on the PReadWriteMutex. More...
 

Protected Attributes

PReadWriteMutexmutex
 

Detailed Description

This class starts a read operation for the PReadWriteMutex on construction and automatically ends the read operation on destruction.

This is very usefull for constructs such as:


    void func()
    {
      PReadWaitAndSignal mutexWait(myMutex);
      if (condition)
        return;
      do_something();
      if (other_condition)
        return;
      do_something_else();
    }

Constructor & Destructor Documentation

PReadWaitAndSignal::PReadWaitAndSignal ( const PReadWriteMutex rw,
PBoolean  start = true 
)

Create the PReadWaitAndSignal wait instance.

This will wait on the specified PReadWriteMutex using the StartRead() function before returning.

Parameters
rwPReadWriteMutex descendent to wait/signal.
startStart read operation on PReadWriteMutex before returning.
PReadWaitAndSignal::~PReadWaitAndSignal ( )

End read operation on the PReadWriteMutex.

This will execute the EndRead() function on the PReadWriteMutex that was used in the construction of this instance.

Member Data Documentation

PReadWriteMutex& PReadWaitAndSignal::mutex
protected

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