NCBI C++ ToolKit
|
#include <corelib/ncbimisc.hpp>
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... | |
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 |