本文整理汇总了C++中CSafeStatic::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ CSafeStatic::erase方法的具体用法?C++ CSafeStatic::erase怎么用?C++ CSafeStatic::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSafeStatic
的用法示例。
在下文中一共展示了CSafeStatic::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Unlock
void CInterProcessLock::Unlock()
{
if (m_Handle == kInvalidLockHandle) {
NCBI_THROW(CInterProcessLockException, eNotLocked,
"Attempt to unlock not-yet-acquired lock");
}
CFastMutexGuard LOCK(s_ProcessLock);
// Check that lock with specified name not already locked
// in the current process.
TLocks::iterator it = s_Locks->find(m_SystemName);
_VERIFY(it != s_Locks->end());
if ( it->second > 1 ) {
// Just decrease reference counter
it->second--;
return;
}
// Release lock
#if defined(NCBI_OS_UNIX)
# if defined(F_TLOCK)
int res = lockf(m_Handle, F_ULOCK, 0);
# elif defined(F_SETLK)
struct flock lockparam;
lockparam.l_type = F_UNLCK;
lockparam.l_whence = SEEK_SET;
lockparam.l_start = 0;
lockparam.l_len = 0; /* whole file */
int res = fcntl(m_Handle, F_SETLK, &lockparam);
# else
# error "No supported lock method. Please port this code."
# endif
if ( res < 0 ) {
NCBI_THROW(CInterProcessLockException, eUnlockError,
"Cannot release the lock");
}
close(m_Handle);
#elif defined(NCBI_OS_MSWIN)
if ( !::ReleaseMutex(m_Handle) ) {
NCBI_THROW(CInterProcessLockException, eUnlockError,
"Cannot release the lock");
}
::CloseHandle(m_Handle);
#endif
m_Handle = kInvalidLockHandle;
s_Locks->erase(m_SystemName);
}