PIP 5.5.3
Platform-Independent Primitives
Public Member Functions | List of all members
PIReadLocker Class Reference

PIReadWriteLock read autolocker More...

#include <pireadwritelock.h>

Public Member Functions

 PIReadLocker (PIReadWriteLock &l, bool condition=true)
 Constructs and lock for read PIReadWriteLock "l" if "condition" is true.
 
 ~PIReadLocker ()
 Release read lock on PIReadWriteLock if "condition" was true.
 

Detailed Description

PIReadWriteLock read autolocker

When a PIReadLocker object is created, it lock PIReadWriteLock for read, if "condition" true. When control leaves the scope in which the PIReadLocker object was created, the PIReadLocker is destructed and unlock for read, if "condition" was true.

If "condition" false this class do nothing.

The PIReadLocker class is non-copyable.

// critical section start
{
PIReadLocker locker(rw_lock);
// ... your read code here
}
// critical section end
PIReadWriteLock read autolocker
Definition: pireadwritelock.h:86