PTLib  Version 2.18.8
 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>

Inheritance diagram for PReadWaitAndSignal:
Collaboration diagram for PReadWaitAndSignal:

Public Member Functions

 PReadWaitAndSignal (const PReadWriteMutex &mutex, bool start=true)
 Create the PReadWaitAndSignal wait instance. More...
 
- Public Member Functions inherited from PReadWriteWaitAndSignalBase
 ~PReadWriteWaitAndSignalBase ()
 

Additional Inherited Members

- Protected Types inherited from PReadWriteWaitAndSignalBase
typedef void(PReadWriteMutex::* StartFn )(const PDebugLocation *location)
 
typedef void(PReadWriteMutex::* EndFn )(const PDebugLocation *location)
 
- Protected Member Functions inherited from PReadWriteWaitAndSignalBase
 PReadWriteWaitAndSignalBase (const PReadWriteMutex &mutex, const PDebugLocation *location, StartFn start, EndFn end)
 
- Protected Attributes inherited from PReadWriteWaitAndSignalBase
PReadWriteMutexm_mutex
 
PDebugLocation m_location
 
EndFn m_end
 

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 mutex,
bool  start = true 
)
inline

Create the PReadWaitAndSignal wait instance.

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

Parameters
mutexPReadWriteMutex descendent to wait/signal.
startStart read operation on PReadWriteMutex before returning.

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