NCBI C++ ToolKit
Classes | Enumerations
guard.hpp File Reference
#include <corelib/ncbimisc.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.

Go to the SVN repository for 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_Base
 Base class for CGuard<> template. More...
 
class  CGuard< Resource, Lock, Unlock, ReportExceptions >
 
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

◆ 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.

Modified on Fri Sep 20 14:57:33 2024 by modify_doxy.py rev. 669887