CAtomicCounter Class Reference
[Atomic Counters]

Search Toolkit Book for CAtomicCounter

#include <ncbicntr.hpp>

Inheritance diagram for CAtomicCounter:

Inheritance graph
[legend]
List of all members.

Detailed Description

CAtomicCounter --.

Define a basic atomic counter.

Provide basic counter operations for an atomic counter represented internally by TNCBIAtomicValue.

Note:
CAtomicCounter has no constructor and is initialized only when created as static object. In all other cases Set(0) must be called to initialize the counter. CAtomicCounter_WithAutoInit can be used instead of CAtomicCounter if the initialization is required.

TNCBIAtomicValue does not imply any assumptions about the size and the signedness of the value. It is at least as big as int datatype and can be signed on some platforms and unsigned on others.

Definition at line 70 of file ncbicntr.hpp.

Public Types

typedef TNCBIAtomicValue TValue
 Alias TValue for TNCBIAtomicValue.

Public Member Functions

TValue Get (void) const THROWS_NONE
 Get atomic counter value.
void Set (TValue new_value) THROWS_NONE
 Set atomic counter value.
TValue Add (int delta) THROWS_NONE
 Atomically add value (=delta), and return new counter value.

Private Attributes

volatile TValue m_Value
 Define NCBI_COUNTER_ADD if one has not been defined. Internal counter value.

Friends

class CObject


Member Typedef Documentation

typedef TNCBIAtomicValue CAtomicCounter::TValue
 

Alias TValue for TNCBIAtomicValue.

Definition at line 73 of file ncbicntr.hpp.


Member Function Documentation

CAtomicCounter::TValue CAtomicCounter::Add int  delta  )  [inline]
 

Atomically add value (=delta), and return new counter value.

Definition at line 248 of file ncbicntr.hpp.

Referenced by CMutableAtomicCounter::Add(), CScopeInfo_Base::AddInfoLock(), CNCMMChainsPool::AddRef(), CNCMMChunksPool::AddRef(), CNetObject::AddRef(), CObject::AddReference(), CGBWorkspace::CGBWorkspace(), CQueue::CountEvent(), CProjectFolder::CProjectFolder(), CTSE_ScopeInfo::CTSE_ScopeInfo(), CWorkspaceFolder::CWorkspaceFolder(), CNCMMCentral::DBPageCreated(), CNCMMCentral::DBPageDeleted(), CObject::DoDeleteThisObject(), CQueue::CStatisticsThread::DoJob(), CObject::DoNotDeleteThisObject(), g_GetNCThreadIndex(), CSeqIdGenerator::GenerateID(), GetBlobReader(), CNetScheduleServer::GetCommandNumber(), CGridGlobals::GetNewJobNumber(), CBDB_Cache::GetNextBlobId(), CNetCacheServer::GetNextBlobId(), CGBProjectHandle::GetNextId(), CQueue::GetNextId(), CQueue::GetNextIdBatch(), CRequestContext::GetNextRequestID(), CDiagContext::GetProcessPostNumber(), CTSE_ScopeLocker::InternalUnlock(), CTSE_ScopeLocker::Lock(), CThreadInPool< TRequest >::Main(), CThreadPool_ServiceThread::NeedCallController(), CThreadInPool< TRequest >::OnExit(), CQueue::ReadJobs(), CNetObject::Release(), CNCMMChainsPool::ReleaseRef(), CNCMMChunksPool::ReleaseRef(), CObject::ReleaseReference(), CScopeInfo_Base::RemoveInfoLock(), CObject::RemoveLastReference(), CObject::RemoveReference(), CThreadNonStop::RequestStop(), CHookDataBase::ResetGlobalHook(), CHookDataBase::ResetLocalHook(), CHookDataBase::ResetPathHook(), multimap_checker< std::multimap< Key, T, Compare > >::RLock(), map_checker< std::map< Key, T, Compare > >::RLock(), multiset< Key, Compare, Allocator >::RLock(), set< ETranslationFrame >::RLock(), multimap_checker< std::multimap< Key, T, Compare > >::RUnlock(), map_checker< std::map< Key, T, Compare > >::RUnlock(), multiset< Key, Compare, Allocator >::RUnlock(), set< ETranslationFrame >::RUnlock(), CTSE_ScopeInfo::SetEditTSE(), CHookDataBase::SetGlobalHook(), CHookDataBase::SetLocalHook(), CHookDataBase::SetPathHook(), CPoolOfThreads< TRequest >::Spawn(), CThreadPool_Impl::TaskFinished(), CThreadPool_Impl::TaskStarting(), CThreadPool_Impl::ThreadStopped(), CTypeRef::Unref(), CTSE_ScopeLocker::UserUnlock(), multimap_checker< std::multimap< Key, T, Compare > >::WLock(), map_checker< std::map< Key, T, Compare > >::WLock(), multiset< Key, Compare, Allocator >::WLock(), set< ETranslationFrame >::WLock(), CFastRWLock::WriteLock(), CNCFileSystem::WriteToFile(), multimap_checker< std::multimap< Key, T, Compare > >::WUnlock(), map_checker< std::map< Key, T, Compare > >::WUnlock(), multiset< Key, Compare, Allocator >::WUnlock(), set< ETranslationFrame >::WUnlock(), CPoolOfThreads< TRequest >::x_AcceptRequest(), CAffinityDict::x_CheckToken(), CNCBlobStorage::x_CreateBlobInCache(), IRemoteAppRequest_Impl::x_CreateWDir(), CNCBlobStorage::x_DeleteBlobFromCache(), CNCFileSystem::x_DoBackgroundWork(), CTSE_Lock::x_Drop(), CSafeStaticPtr_Base::x_GetCreationOrder(), CThreadPool_ServiceThread::x_Idle(), CTSE_Lock::x_Lock(), CTSE_Lock::x_Relock(), CThreadPool_Task::x_ResetOwner(), CDataSource::x_SetLoadLock(), CThreadPool_Task::x_SetOwner(), CTSE_Lock::x_Unlock(), and CTSE_ScopeInfo::~CTSE_ScopeInfo().

CAtomicCounter::TValue CAtomicCounter::Get void   )  const [inline]
 

Get atomic counter value.

Definition at line 160 of file ncbicntr.hpp.

References m_Value, NCBI_SCHED_SPIN_INIT, and NCBI_SCHED_SPIN_YIELD.

Referenced by CTSE_ScopeInfo::AddUsedTSE(), CObject::CanBeDeleted(), CObject::DeleteThis(), CObject::DoDeleteThisObject(), CQueue::CStatisticsThread::DoJob(), CObject::DoNotDeleteThisObject(), CHookDataBase::Empty(), CDataSource_ScopeInfo::ForgetTSELock(), CSeqIdGenerator::GenerateID(), CMutableAtomicCounter::Get(), CSeqIdGenerator::GetCounter(), CThreadPool_Impl::GetExecutingTasksCount(), CQueue::GetNextId(), CQueue::GetNextIdBatch(), CDiagContext::GetProcessPostNumber(), CNetObject::GetRefCount(), CThreadPool_Impl::GetThreadsCount(), CHookDataBase::HaveHooks(), CObject::IsAllocatedInPool(), CTSE_ScopeInfo::IsLocked(), CTSE_Info::IsLocked(), CNetScheduleServer::IsLog(), CThreadNonStop::IsStopRequested(), CStdPoolOfThreads::KillAllThreads(), CTSE_ScopeInfo::LockedMoreThanOnce(), CThreadNonStop::Main(), CObject::operator delete(), CThreadPool_Task::operator=(), CNCBlobStorage::PrintStat(), CQueue::ReadJobs(), CObject::Referenced(), CObject::ReferencedOnlyOnce(), CDataSource_ScopeInfo::ReleaseTSELock(), CTSE_ScopeInfo::RemoveLastInfoLock(), CHookDataBase::ResetGlobalHook(), CHookDataBase::ResetLocalHook(), multimap_checker< std::multimap< Key, T, Compare > >::RLock(), map_checker< std::map< Key, T, Compare > >::RLock(), multiset< Key, Compare, Allocator >::RLock(), set< ETranslationFrame >::RLock(), multimap_checker< std::multimap< Key, T, Compare > >::RUnlock(), map_checker< std::map< Key, T, Compare > >::RUnlock(), multiset< Key, Compare, Allocator >::RUnlock(), set< ETranslationFrame >::RUnlock(), CHookDataBase::SetGlobalHook(), CHookDataBase::SetLocalHook(), CDataSource_ScopeInfo::UpdateTSELock(), multimap_checker< std::multimap< Key, T, Compare > >::WLock(), map_checker< std::map< Key, T, Compare > >::WLock(), multiset< Key, Compare, Allocator >::WLock(), set< ETranslationFrame >::WLock(), CFastRWLock::WriteLock(), multimap_checker< std::multimap< Key, T, Compare > >::WUnlock(), map_checker< std::map< Key, T, Compare > >::WUnlock(), multiset< Key, Compare, Allocator >::WUnlock(), set< ETranslationFrame >::WUnlock(), CPoolOfThreads< TRequest >::x_AcceptRequest(), CThreadPool_Impl::x_CanAddImmediateTask(), CTSE_ScopeInfo::x_CheckAdded(), CAffinityDict::x_CheckToken(), CNCFileSystem::x_DoBackgroundWork(), CNCBlobStorage::x_GC_CollectPartsStatistics(), CTSE_Lock::x_Relock(), CTSE_ScopeInfo::x_RestoreAdded(), CTSE_ScopeInfo::x_SameTSE(), CSyncQueue< Type, Container >::x_Unlock(), CHookDataBase::~CHookDataBase(), CObject::~CObject(), CPoolOfThreads< TRequest >::~CPoolOfThreads(), CSeq_id_Info::~CSeq_id_Info(), CSQLITE3_Cache::~CSQLITE3_Cache(), CTSE_Info::~CTSE_Info(), CTSE_ScopeInfo::~CTSE_ScopeInfo(), and CTypeInfoSource::~CTypeInfoSource().

void CAtomicCounter::Set TValue  new_value  )  [inline]
 

Set atomic counter value.

Definition at line 177 of file ncbicntr.hpp.

Referenced by CAffinityDict::Attach(), CAffinityDict::CAffinityDict(), CAtomicCounter_WithAutoInit::CAtomicCounter_WithAutoInit(), CNetCacheServer::CNetCacheServer(), CNetScheduleServer::CNetScheduleServer(), CPoolOfThreads< TRequest >::CPoolOfThreads(), CQueueWorkerNodeList::CQueueWorkerNodeList(), CScheduler_MT::CScheduler_MT(), CThreadPool_ServiceThread::CThreadPool_ServiceThread(), g_InitNCThreadIndexes(), CBDB_Cache::GetNextBlobId(), CQueue::GetNextId(), CQueue::GetNextIdBatch(), CObject::InitCounter(), CNCFileSystem::Initialize(), CNCMMChainsPool::InitInstance(), CNCMMChunksPool::InitInstance(), CObject::operator new(), CQueue::ReadJobs(), CMutableAtomicCounter::Set(), CSeqIdGenerator::SetCounter(), CNetScheduleServer::SetLogging(), CNetScheduleServer::SetNSParameters(), CNCMMCentral::x_CalcMemoryMode(), CAffinityDict::x_CheckToken(), CThreadPool_Impl::x_Init(), and CObject::~CObject().


Friends And Related Function Documentation

friend class CObject [friend]
 

Definition at line 97 of file ncbicntr.hpp.


Member Data Documentation

volatile TValue CAtomicCounter::m_Value [private]
 

Define NCBI_COUNTER_ADD if one has not been defined. Internal counter value.

Definition at line 93 of file ncbicntr.hpp.

Referenced by Get(), and CObject::InitCounter().


The documentation for this class was generated from the following file:
Generated on Mon Dec 7 10:05:57 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:22:32 2009 by modify_doxy.py rev. 173732