libcommonc++  0.7
ScopedLock Class Reference

A convenience object for lexical scope based synchronization. More...

#include <ScopedLock.h++>

Public Member Functions

 ScopedLock (Lock &lock)
 Construct a new Scopedock for the given Lock. More...
 
 ~ScopedLock ()
 Destructor. More...
 

Detailed Description

A convenience object for lexical scope based synchronization.

ScopedLock locks a Lock in its constructor and unlocks it in its destructor.

A block of code can be conveniently protected by a ScopedLock by using the synchronized() macro, e.g.:

Mutex mutex;
synchronized(mutex)
{
  // thread-exclusive code here
}
Author
Mark Lindner

Constructor & Destructor Documentation

◆ ScopedLock()

ScopedLock ( Lock lock)
inline

Construct a new Scopedock for the given Lock.

The Lock is locked immediately.

◆ ~ScopedLock()

~ScopedLock ( )
inline

Destructor.

Unlocks the Lock.


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