#ifndef ROOT_TVirtualMutex
#define ROOT_TVirtualMutex
#ifndef ROOT_TObject
#include "TObject.h"
#endif
class TVirtualMutex;
R__EXTERN TVirtualMutex *gGlobalMutex;
class TVirtualMutex : public TObject {
public:
TVirtualMutex(Bool_t = kFALSE) { }
virtual ~TVirtualMutex() { }
virtual Int_t Lock() = 0;
virtual Int_t TryLock() = 0;
virtual Int_t UnLock() = 0;
virtual Int_t CleanUp() = 0;
Int_t Acquire() { return Lock(); }
Int_t Release() { return UnLock(); }
virtual TVirtualMutex *Factory(Bool_t = kFALSE) = 0;
ClassDef(TVirtualMutex,0)
};
class TLockGuard {
private:
TVirtualMutex *fMutex;
TLockGuard(const TLockGuard&);
TLockGuard& operator=(const TLockGuard&);
public:
TLockGuard(TVirtualMutex *mutex)
: fMutex(mutex) { if (fMutex) fMutex->Lock(); }
virtual ~TLockGuard() { if (fMutex) fMutex->UnLock(); }
ClassDef(TLockGuard,0)
};
#if defined (_REENTRANT) || defined (WIN32)
#define R__LOCKGUARD(mutex) TLockGuard R__guard(mutex)
#define R__LOCKGUARD2(mutex) \
if (gGlobalMutex && !mutex) { \
gGlobalMutex->Lock(); \
if (!mutex) \
mutex = gGlobalMutex->Factory(kTRUE); \
gGlobalMutex->UnLock(); \
} \
R__LOCKGUARD(mutex)
#else
#define R__LOCKGUARD(mutex) if (mutex) { }
#define R__LOCKGUARD2(mutex) if (mutex) { }
#endif
#endif
Last change: Wed Jun 25 08:54:54 2008
Last generated: 2008-06-25 08:54
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.