PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PIWriteLocker Class Reference

Scope guard that acquires writer access in constructor and releases it in destructor. More...

#include <pireadwritelock.h>

Public Member Functions

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

Detailed Description

Scope guard that acquires writer access in constructor and releases it in destructor.

PIReadWriteLock write autolocker

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

If "condition" false this class do nothing.

The PIWriteLocker class is non-copyable.

// critical section start
{
PIWriteLocker locker(rw_lock);
// ... your write code here
}
// critical section end
Scope guard that acquires writer access in constructor and releases it in destructor.
Definition: pireadwritelock.h:117