NCBI C++ ToolKit
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CMiniMutex Class Reference

Search Toolkit Book for CMiniMutex

Mutex created to have minimum possible size (its size is 4 bytes) and to sleep using kernel capabilities (without busy-loops). More...

#include "srv_sync.hpp"
(Private to src/app/netcache.)

+ Collaboration diagram for CMiniMutex:

Public Member Functions

 CMiniMutex (void)
 
 ~CMiniMutex (void)
 
void Lock (void)
 Lock the mutex. More...
 
bool TryLock (void)
 Quickly try to lock mutex (without any retries). More...
 
void Unlock (void)
 Unlock the mutex. More...
 

Private Member Functions

 CMiniMutex (const CMiniMutex &)
 Prohibit copying of the object. More...
 
CMiniMutexoperator= (const CMiniMutex &)
 

Private Attributes

CFutex m_Futex
 Futex which is used as base for mutex implementation. More...
 

Detailed Description

Mutex created to have minimum possible size (its size is 4 bytes) and to sleep using kernel capabilities (without busy-loops).

Definition at line 192 of file srv_sync.hpp.

Constructor & Destructor Documentation

◆ CMiniMutex() [1/2]

CMiniMutex::CMiniMutex ( void  )
inline

Definition at line 263 of file srv_sync.hpp.

References m_Futex, and CFutex::SetValueNonAtomic().

◆ ~CMiniMutex()

CMiniMutex::~CMiniMutex ( void  )
inline

Definition at line 269 of file srv_sync.hpp.

References _ASSERT, CFutex::GetValue(), and m_Futex.

◆ CMiniMutex() [2/2]

CMiniMutex::CMiniMutex ( const CMiniMutex )
private

Prohibit copying of the object.

Member Function Documentation

◆ Lock()

void CMiniMutex::Lock ( void  )

Lock the mutex.

Mutex doesn't support recursive locking. So if current thread has already locked this mutex second call will result in deadlock.

Definition at line 108 of file srv_sync.cpp.

References _ASSERT, CFutex::AddValue(), CFutex::eValueChanged, CFutex::GetValue(), m_Futex, val, and CFutex::WaitValueChange().

Referenced by CNCAlerts::Acknowledge(), CNCStat::AddAllStats(), SNCBlobVerData::AddChunkMem(), CNCSyncLog::AddEvent(), CTaskServer::AddListeningPort(), CTaskServer::AddShutdownCallback(), CNCPeerControl::AddSyncControl(), CNCPeerControl::AssignClientConn(), CSrvTransitionTask::CancelTransRequest(), CNCStat::ClientBlobRead(), CNCStat::ClientBlobWrite(), CNCStat::CmdFinished(), CNCActiveSyncControl::CmdFinished(), CNCStat::CmdStarted(), CSrvStat::CollectThreads(), CNCStat::CollectThreads(), CNCStat::ConnClosing(), CNCPeerControl::CreateNewSocket(), CSrvTask::CSrvTask(), CNCBlobVerManager::DataWritten(), CNCStat::DBFileCleaned(), CNCBlobVerManager::DeadTimeChanged(), CNCBlobVerManager::DeleteDeadVersion(), SNCBlobVerData::DeleteThis(), CNCBlobVerManager::DeleteVersion(), CNCStat::DiskBlobWrite(), CNCLogCleaner::ExecuteSlice(), CLogWriter::ExecuteSlice(), CMMFlusher::ExecuteSlice(), SNCBlobVerData::ExecuteSlice(), CNCBlobVerManager::ExecuteSlice(), CNCPeerControl::ExecuteSlice(), CNewFileCreator::ExecuteSlice(), CRecNoSaver::ExecuteSlice(), CNCBlobVerManager::FinalizeWriting(), CNCBlobStorage::FindBlob(), CNCPeerControl::FindIPbyAlias(), CNCPeerControl::FindIPbyName(), CNCPeerControl::FinishSync(), CSrvTransitionTask::FinishTransition(), FireAllTimers(), CNCDistributionConf::GenerateBlobKey(), CNCBlobVerManager::Get(), CNCPeerControl::GetBGConn(), CNCBlobStorage::GetBList(), CNCStat::GetCntRunningCmds(), CNCBlobVerManager::GetCurVersion(), CNCBlobStorage::GetFullBlobsList(), CNCBlobStorage::GetLatestBlobExpire(), CNCBlobStorage::GetMaxSyncLogRecNo(), CNCPeerControl::GetPeerNameOrEmpty(), CNCBlobAccessor::GetPurgeData(), CNCBlobStorage::GetPurgeData(), CNCPeerControl::GetReadyForShutdown(), CNCStat::GetStat(), CNCPeerControl::HasPeerInThrottle(), CNCBlobAccessor::HasPutSucceeded(), CNCPeerControl::Initialize(), CNCBlobAccessor::IsPurged(), CNCPeerControl::Peer(), CNCPeerControl::PrintState(), CNCPeerControl::PrintSyncStat(), CNCStat::PrintToLogs(), CNCStat::PrintToSocket(), CNCBlobAccessor::Purge(), CNCPeerControl::PutConnToPool(), CNCBlobAccessor::PutFailed(), CNCBlobAccessor::PutSucceeded(), RCUFinalizeThread(), RCUInitNewThread(), CNCPeerControl::ReadCurState(), CNCPeerShutdown::ReadyForShutdown(), CNCPeriodicSync::ReConfig(), CNCAlerts::Register(), CNCBlobVerManager::Release(), CNCBlobStorage::ReleaseCacheData(), CNCPeerControl::ReleaseConn(), CNCPeerControl::RemoveSyncControl(), RemoveTaskFromTimer(), CNCAlerts::Report(), SNCBlobVerData::RequestDataWrite(), SNCBlobVerData::RequestMemRelease(), CNCBlobVerManager::RequestMemRelease(), RequestThreadRevive(), RequestThreadStart(), RequestThreadStop(), CSrvTransitionTask::RequestTransition(), CSrvTask::RunAfter(), s_AddCurrentMem(), s_AddReleasableMem(), s_AddReleasingMem(), s_AddTaskToQueue(), s_AllocMemory(), s_AllocWriteBackMem(), s_BalanceTasks(), s_CollectWBData(), s_CreateNewFile(), s_DeallocMemory(), s_DeleteDBFile(), s_DeleteIndexRec(), s_DrainPool(), s_FillFromFreePages(), s_FillFromPage(), s_FillPool(), s_FindServerSlot(), s_FreeWriteBackMem(), s_GetDBFile(), s_GetDBFileTry(), s_GetFromGlobal(), s_GetKeyCacheData(), s_GetNextWriteCoord(), s_IsReadyForShutdown(), s_MoveRecToGarbage(), s_NotifyConsumers(), s_PerJiffyTasks_Worker(), s_PutToFreeList(), s_QueueLogWrite(), s_RCUNoteGPorStartNew(), s_RegisterNewThread(), s_ReleaseToFreePages(), s_RemoveFromFreeList(), s_ResetExecTime(), s_ScheduleVerDelete(), s_SetNextTime(), s_ShiftStats(), s_StartCurMgrThread(), s_StopCurMgrThread(), s_SubCurrentMem(), s_SubReleasableMem(), s_SubReleasingMem(), s_UnqueueTask(), s_WorkerThreadMain(), CNCStat::SaveCurStateStat(), CSrvStat::SaveEndStateStat(), SchedIsAllIdle(), CSrvStat::SchedJiffyStat(), SNCBlobVerData::SetCurrent(), CNCBlobAccessor::SetFailedWriteCount(), SNCBlobVerData::SetNonReleasable(), SNCBlobVerData::SetNotCurrent(), SNCBlobVerData::SetReleasable(), CSrvStat::SockClose(), TimerTick(), CNCStat::TransferEndState(), CNCBlobAccessor::UpdatePurgeData(), CNCBlobStorage::WriteBlobList(), CNCBlobStorage::WriteBlobStat(), CNCBlobStorage::WriteDbInfo(), CNCPeerControl::x_AddMirrorEvent(), CNCActiveSyncControl::x_CheckSlotOurSync(), CNCActiveSyncControl::x_CheckSlotTheirSync(), CBlobCacher::x_CreateInitialFile(), CNCPeerControl::x_CreateNewConn(), CExpiredCleaner::x_DeleteNextData(), CNCPeerControl::x_DoReleaseConn(), SNCBlobVerData::x_ExecuteWriteAll(), CNCActiveSyncControl::x_FinishScanSlots(), CBulkCleaner::x_FinishSession(), CDiskFlusher::x_FlushNextFile(), CSpaceShrinker::x_MoveNextRecord(), CSpaceShrinker::x_MoveRecord(), CSpaceShrinker::x_PrepareToShrink(), CNCPeerControl::x_ProcessUpdateEvent(), CBlobCacher::x_StartCaching(), CBulkCleaner::x_StartSession(), CNCPeerControl::x_UnreserveBGConn(), CNCActiveSyncControl::x_WaitForExecutingTasks(), SNCBlobVerData::x_WriteCurChunk(), and CSrvTask::~CSrvTask().

◆ operator=()

CMiniMutex& CMiniMutex::operator= ( const CMiniMutex )
private

◆ TryLock()

bool CMiniMutex::TryLock ( void  )
inline

Quickly try to lock mutex (without any retries).

Returns TRUE if lock was successful and Unlock() should be called, FALSE otherwise.

Definition at line 275 of file srv_sync.hpp.

References CFutex::ChangeValue(), CFutex::GetValue(), and m_Futex.

◆ Unlock()

void CMiniMutex::Unlock ( void  )

Unlock the mutex.

Mutex doesn't check whether this thread actually locked it. If you call Unlock() without calling Lock() behavior is undefined.

Definition at line 119 of file srv_sync.cpp.

References _ASSERT, CFutex::AddValue(), m_Futex, val, and CFutex::WakeUpWaiters().

Referenced by CNCAlerts::Acknowledge(), CNCStat::AddAllStats(), SNCBlobVerData::AddChunkMem(), CNCSyncLog::AddEvent(), CTaskServer::AddListeningPort(), CTaskServer::AddShutdownCallback(), CNCPeerControl::AddSyncControl(), CNCPeerControl::AssignClientConn(), CSrvTransitionTask::CancelTransRequest(), CNCStat::ClientBlobRead(), CNCStat::ClientBlobWrite(), CNCStat::CmdFinished(), CNCActiveSyncControl::CmdFinished(), CNCStat::CmdStarted(), CSrvStat::CollectThreads(), CNCStat::CollectThreads(), CNCStat::ConnClosing(), CNCPeerControl::CreateNewSocket(), CSrvTask::CSrvTask(), CNCBlobVerManager::DataWritten(), CNCStat::DBFileCleaned(), CNCBlobVerManager::DeadTimeChanged(), CNCBlobVerManager::DeleteDeadVersion(), SNCBlobVerData::DeleteThis(), CNCBlobVerManager::DeleteVersion(), CNCStat::DiskBlobWrite(), CNCLogCleaner::ExecuteSlice(), CLogWriter::ExecuteSlice(), CMMFlusher::ExecuteSlice(), SNCBlobVerData::ExecuteSlice(), CNCBlobVerManager::ExecuteSlice(), CNCPeerControl::ExecuteSlice(), CNewFileCreator::ExecuteSlice(), CRecNoSaver::ExecuteSlice(), CNCBlobVerManager::FinalizeWriting(), CNCBlobStorage::FindBlob(), CNCPeerControl::FindIPbyAlias(), CNCPeerControl::FindIPbyName(), CNCPeerControl::FinishSync(), CSrvTransitionTask::FinishTransition(), FireAllTimers(), CNCDistributionConf::GenerateBlobKey(), CNCBlobVerManager::Get(), CNCPeerControl::GetBGConn(), CNCBlobStorage::GetBList(), CNCStat::GetCntRunningCmds(), CNCBlobVerManager::GetCurVersion(), CNCBlobStorage::GetFullBlobsList(), CNCBlobStorage::GetLatestBlobExpire(), CNCBlobStorage::GetMaxSyncLogRecNo(), CNCActiveSyncControl::GetNextTask(), CNCPeerControl::GetPeerNameOrEmpty(), CNCBlobAccessor::GetPurgeData(), CNCBlobStorage::GetPurgeData(), CNCPeerControl::GetReadyForShutdown(), CNCStat::GetStat(), CNCPeerControl::HasPeerInThrottle(), CNCBlobAccessor::HasPutSucceeded(), CNCPeerControl::Initialize(), CNCBlobAccessor::IsPurged(), CNCPeerControl::Peer(), CNCPeerControl::PrintState(), CNCPeerControl::PrintSyncStat(), CNCStat::PrintToLogs(), CNCStat::PrintToSocket(), CNCBlobAccessor::Purge(), CNCPeerControl::PutConnToPool(), CNCBlobAccessor::PutFailed(), CNCBlobAccessor::PutSucceeded(), RCUFinalizeThread(), RCUInitNewThread(), CNCPeerControl::ReadCurState(), CNCPeerShutdown::ReadyForShutdown(), CNCPeriodicSync::ReConfig(), CNCAlerts::Register(), CNCBlobVerManager::Release(), CNCBlobStorage::ReleaseCacheData(), CNCPeerControl::ReleaseConn(), CNCPeerControl::RemoveSyncControl(), RemoveTaskFromTimer(), CNCAlerts::Report(), SNCBlobVerData::RequestDataWrite(), SNCBlobVerData::RequestMemRelease(), CNCBlobVerManager::RequestMemRelease(), RequestThreadRevive(), RequestThreadStart(), RequestThreadStop(), CSrvTransitionTask::RequestTransition(), CSrvTask::RunAfter(), s_AddCurrentMem(), s_AddReleasableMem(), s_AddReleasingMem(), s_AddTaskToQueue(), s_AllocMemory(), s_AllocWriteBackMem(), s_BalanceTasks(), s_CollectWBData(), s_CreateNewFile(), s_DeallocMemory(), s_DeleteDBFile(), s_DeleteIndexRec(), s_DrainPool(), s_FillFromFreePages(), s_FillFromPage(), s_FillPool(), s_FindServerSlot(), s_FreeWriteBackMem(), s_GetDBFile(), s_GetDBFileTry(), s_GetFromGlobal(), s_GetKeyCacheData(), s_GetNextWriteCoord(), s_IsReadyForShutdown(), s_MoveRecToGarbage(), s_NotifyConsumers(), s_PerJiffyTasks_Worker(), s_PutToFreeList(), s_QueueLogWrite(), s_RCUNoteGPorStartNew(), s_RegisterNewThread(), s_ReleaseToFreePages(), s_RemoveFromFreeList(), s_ResetExecTime(), s_ScheduleVerDelete(), s_SetNextTime(), s_ShiftStats(), s_StartCurMgrThread(), s_StopCurMgrThread(), s_SubCurrentMem(), s_SubReleasableMem(), s_SubReleasingMem(), s_UnqueueTask(), s_WorkerThreadMain(), CNCStat::SaveCurStateStat(), CSrvStat::SaveEndStateStat(), SchedIsAllIdle(), CSrvStat::SchedJiffyStat(), SNCBlobVerData::SetCurrent(), CNCBlobAccessor::SetFailedWriteCount(), SNCBlobVerData::SetNonReleasable(), SNCBlobVerData::SetNotCurrent(), SNCBlobVerData::SetReleasable(), CSrvStat::SockClose(), TimerTick(), CNCStat::TransferEndState(), CNCBlobAccessor::UpdatePurgeData(), CNCBlobStorage::WriteBlobList(), CNCBlobStorage::WriteBlobStat(), CNCBlobStorage::WriteDbInfo(), CNCPeerControl::x_AddMirrorEvent(), CNCPeerControl::x_AssignClientConn(), CBlobCacher::x_CancelCaching(), CNCActiveSyncControl::x_CheckSlotOurSync(), CNCActiveSyncControl::x_CheckSlotTheirSync(), CBlobCacher::x_CreateInitialFile(), CNCPeerControl::x_CreateNewConn(), CExpiredCleaner::x_DeleteNextData(), CNCPeerControl::x_DoReleaseConn(), SNCBlobVerData::x_ExecuteWriteAll(), CBlobCacher::x_FinishCaching(), CNCActiveSyncControl::x_FinishScanSlots(), CBulkCleaner::x_FinishSession(), CDiskFlusher::x_FlushNextFile(), CNCPeerControl::x_GetBGConnImpl(), CSpaceShrinker::x_MoveNextRecord(), CSpaceShrinker::x_MoveRecord(), CSpaceShrinker::x_PrepareToShrink(), CNCPeerControl::x_ProcessUpdateEvent(), CNCBlobVerManager::x_ReleaseMgr(), CBulkCleaner::x_StartSession(), CNCPeerControl::x_UnreserveBGConn(), CNCActiveSyncControl::x_WaitForExecutingTasks(), SNCBlobVerData::x_WriteCurChunk(), and CSrvTask::~CSrvTask().

Member Data Documentation

◆ m_Futex

CFutex CMiniMutex::m_Futex
private

Futex which is used as base for mutex implementation.

Definition at line 216 of file srv_sync.hpp.

Referenced by CMiniMutex(), Lock(), TryLock(), Unlock(), and ~CMiniMutex().


The documentation for this class was generated from the following files:
Modified on Sat Feb 24 07:48:46 2024 by modify_doxy.py rev. 669887