1 #ifndef CORELIB___GUARD__HPP
2 #define CORELIB___GUARD__HPP
47 template <
class Resource>
63 template <
class Resource>
109 static void ReportException(std::exception& ex);
113 template <
class Resource,
157 }
catch(std::exception& ex) {
159 if (ReportExceptions ==
eReport) {
Base class for CGuard<> template.
static void ReportException(std::exception &ex)
EReportExceptions
Exception reporting options.
@ eReport
Use ERR_POST to report exceptions.
~CGuard()
Destructor releases the resource.
CGuard(const CGuard< resource_type, lock_type, unlock_type > &)
void operator=(const CGuard< resource_type, lock_type, unlock_type > &)
void Guard(resource_type &resource)
Manually force the guard to protect some other resource.
CGuard(resource_type &resource, const lock_type &lock, const unlock_type &unlock=unlock_type())
This constructor locks the resource passed.
pair_base_member< lock_type, pair_base_member< unlock_type, resource_ptr > > m_Data
Maintain a pointer to the original resource that is being guarded.
unlock_type & GetUnlock(void)
CGuard(resource_type &resource)
This constructor locks the resource passed.
CGuard< Resource, Lock, Unlock, ReportExceptions > TThisType
resource_ptr & GetResource(void)
void Release()
Manually force the resource to be released.
CGuard(EEmptyGuard, const lock_type &lock, const unlock_type &unlock=unlock_type())
resource_type * resource_ptr
lock_type & GetLock(void)
CNoLock is a simple no-op lock which does no real locking.
CGuard< CNoLock > TReadLockGuard
CGuard< CNoLock > TWriteLockGuard
Template used for empty base class optimization.
const first_type & first() const
const second_type & second() const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define NCBI_XNCBI_EXPORT
EEmptyGuard
class CGuard<> implements a templatized "resource acquisition is initialization" (RAII) locking guard...
Miscellaneous common-use basic types and functionality.
SSimpleLock is a functor to wrap calling Lock().
void operator()(resource_type &resource) const
SSimpleLock is a functor to wrap calling Unlock().
void operator()(resource_type &resource) const