PInterProcessLock – Helper functor for CGuard<> to e.g. help specify the waiting timeout.
CInterProcessLock ipl("MyLock"); CInterProcessLock_Guard ipl_guard (ipl, PInterProcessLock(3.456, 0.333));
#ifndef CORELIB___INTERPROCESS_LOCK__HPP
#define CORELIB___INTERPROCESS_LOCK__HPP
#if !defined(NCBI_OS_MSWIN) && !defined(NCBI_OS_UNIX)
# error "CInterProcessLock is not implemented on this platform"
#endif
{
public:
void Unlock(void);
bool TryLock(void);
void Remove(void);
const string& GetName(void) const { return m_Name; }
const string& GetSystemName(void) const { return m_SystemName; }
private:
string m_Name;
string m_SystemName;
#if defined(NCBI_OS_UNIX)
typedef int TLockHandle;
#elif defined(NCBI_OS_MSWIN)
#endif
TLockHandle m_Handle;
};
{
public:
{
}
{
}
private:
};
{
public:
enum EErrCode {
eLockTimeout,
eNameError,
eCreateError,
eLockError,
eUnlockError,
eMultipleLocks,
eNotLocked
};
virtual const char* GetErrCodeString(void) const override;
};
#endif
CInterProcessLockException –.
CTimeout – Timeout interval.
#define NCBI_EXCEPTION_DEFAULT(exception_class, base_class)
To help declare new exception class.
PInterProcessLock(const CTimeout &timeout, const CTimeout &granularity=CTimeout(CTimeout::eInfinite))
CGuard< CInterProcessLock, PInterProcessLock > CInterProcessLock_Guard
Convenience typedef for PInterProcessLock.
CInterProcessLock resource_type
void operator()(resource_type &resource) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
@ eInfinite
Infinite timeout.
#define NCBI_XNCBI_EXPORT
#define HANDLE
An abstraction for a file handle.
Defines: CTimeFormat - storage class for time format.