Locker Class Reference

Inheritance diagram for Locker:

NonCopyable List of all members.

Detailed Description

Locker guard.

This class holds the synchronization object: constructor locks this object and destructor unlocks this object.

For example, the following code:

  void f(Lockable &x)
  {
    x.enter();
    // ...
    x.leave();
  }

can be rewritten as:

  void f(Lockable &x)
  {
    Locker guard(x);
    // ...
  }

Even exception was thrown during function execution, the synchronization object will be properly unlocked.

Public Member Functions


Constructor & Destructor Documentation

Locker ( Lockable lock  )  [explicit]

Lock synchronization object.

This constructor hold the synchronization object lock. And lock it by Lockable::enter() method calling.

Parameters:
[in,out] lock Synchronization object.
See also:
Lockable::enter()

~Locker (  ) 

Unlock synchronization object.

The destructor unlock the locked in constructor synchronization object.

See also:
Lockable::leave()


Generated on Wed Jun 6 17:27:47 2007 for OMNI by  doxygen 1.5.2