include/corelib/guard.hpp File Reference

#include <corelib/ncbidbg.hpp>

Include dependency graph for guard.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SSimpleLock< Resource >
 SSimpleLock is a functor to wrap calling Lock(). More...
struct  SSimpleUnlock< Resource >
 SSimpleLock is a functor to wrap calling Unlock(). More...
class  CGuard< Resource, Lock, Unlock >
class  CNoLock
 CNoLock is a simple no-op lock which does no real locking. More...

Enumerations

enum  EEmptyGuard { eEmptyGuard }
 class CGuard<> implements a templatized "resource acquisition is initialization" (RAII) locking guard. More...


Enumeration Type Documentation

enum EEmptyGuard
 

class CGuard<> implements a templatized "resource acquisition is initialization" (RAII) locking guard.

This guard is useful for locking resources in an exception-safe manner. The classic use of this is to lock a mutex within a C++ scope, as follows:

void SomeFunction() { CGuard<CMutex> GUARD(some_mutex); [...perform some thread-safe operations...] }

If an exception is thrown during the performance of any operations while the guard is held, the guarantee of C++ stack-unwinding will force the guard's destructor to release whatever resources were acquired.

Enumerator:
eEmptyGuard 

Definition at line 93 of file guard.hpp.


Generated on Sun Dec 6 23:18:08 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:21:19 2009 by modify_doxy.py rev. 173732