NCBI C++ ToolKit
|
Macros | |
#define | NCBI_SCHED_YIELD() ::SwitchToThread() |
#define | NCBI_SCHED_SPIN_INIT() int spin_counter = 0 |
#define | NCBI_SCHED_SPIN_YIELD() if ( !(++spin_counter & 3) ) ::SwitchToThread() |
#define | NCBI_COUNTER_ASM_OK 1 |
#define | NCBI_ATOMIC_TYPE(t) std::atomic<t> |
#define | NCBI_COUNTER_UNSIGNED 1 |
#define | NCBI_COUNTER_USE_STD_ATOMIC 1 |
#define | NCBI_COUNTER_ADD(p, d) ((*p) += d) |
#define | NCBI_SWAP_POINTERS(loc, nv) (InterlockedExchangePointer(loc, nv)) |
#define | INTERNAL_MUTEX_DEBUG |
Mutex debug setting. More... | |
#define | SYSTEM_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
#define | NCBI_NAMESPACE_MUTEX ncbi_namespace_mutex_mt |
#define | THREAD_SYSTEM_ID_INITIALIZER 0 |
Use in defining initial value of system mutex. More... | |
#define | STATIC_FAST_MUTEX_INITIALIZER { SYSTEM_MUTEX_INITIALIZER, NCBI_NS_NCBI::SSystemFastMutex::eMutexInitialized } |
Determine type of system mutex initialization. More... | |
#define | DEFINE_STATIC_FAST_MUTEX(id) static NCBI_NS_NCBI::SSystemFastMutex id = STATIC_FAST_MUTEX_INITIALIZER |
Define static fast mutex and initialize it. More... | |
#define | DECLARE_CLASS_STATIC_FAST_MUTEX(id) static NCBI_NS_NCBI::SSystemFastMutex id |
Declare static fast mutex. More... | |
#define | DEFINE_CLASS_STATIC_FAST_MUTEX(id) NCBI_NS_NCBI::SSystemFastMutex id = STATIC_FAST_MUTEX_INITIALIZER |
Define fast mutex and initialize it. More... | |
#define | STATIC_MUTEX_INITIALIZER { STATIC_FAST_MUTEX_INITIALIZER, THREAD_SYSTEM_ID_INITIALIZER, 0 } |
Define static mutex initializer. More... | |
#define | DEFINE_STATIC_MUTEX(id) static NCBI_NS_NCBI::SSystemMutex id = STATIC_MUTEX_INITIALIZER |
Define static mutex and initialize it. More... | |
#define | DECLARE_CLASS_STATIC_MUTEX(id) static NCBI_NS_NCBI::SSystemMutex id |
Declare static mutex. More... | |
#define | DEFINE_CLASS_STATIC_MUTEX(id) NCBI_NS_NCBI::SSystemMutex id = STATIC_MUTEX_INITIALIZER |
Define mutex and initialize it. More... | |
#define | NCBI_HAVE_CONDITIONAL_VARIABLE |
CConditionVariable –. More... | |
#define | DECLARE_TLS_VAR(type, var) CSimpleStaticTls<type> var |
#define | NCBI_STATIC_TLS_VIA_SAFE_STATIC_REF 1 |
Friends | |
struct | ncbi_namespace_mutex_mt::SSystemFastMutex::SSystemMutex |
class | ncbi_namespace_mutex_mt::SSystemFastMutex::::ncbi::CAutoInitializeStaticFastMutex |
class | ncbi_namespace_mutex_mt::SSystemFastMutex::::ncbi::CFastMutex |
class | ncbi_namespace_mutex_mt::SSystemFastMutex::::ncbi::CSafeStaticPtr_Base |
class | ncbi_namespace_mutex_mt::SSystemMutex::::ncbi::CAutoInitializeStaticMutex |
class | ncbi_namespace_mutex_mt::SSystemMutex::::ncbi::CMutex |
class | CFastMutex::CRWLock |
class | CMutex::CRWLock |
Allow use of m_Mtx and m_Owner members directly. More... | |
class | CRWLockHolder::CYieldingRWLock |
class | CYieldingRWLock::CRWLockHolder |
class | CTlsBase::CRef< CTlsBase > |
class | CTlsBase::CUsedTlsBases |
class | CTlsBase::CStaticTlsHelper |
class | CStaticTls< TValue >::CUsedTlsBases |
class | CThread::CRef< CThread > |
class | CThread::CTlsBase |
class | CThread::CNcbiApplicationAPI |
TWrapperRes | CThread::ThreadWrapperCaller (TWrapperArg arg) |
#define DECLARE_CLASS_STATIC_FAST_MUTEX | ( | id | ) | static NCBI_NS_NCBI::SSystemFastMutex id |
Declare static fast mutex.
Definition at line 500 of file ncbimtx.hpp.
#define DECLARE_CLASS_STATIC_MUTEX | ( | id | ) | static NCBI_NS_NCBI::SSystemMutex id |
Declare static mutex.
Definition at line 516 of file ncbimtx.hpp.
#define DECLARE_TLS_VAR | ( | type, | |
var | |||
) | CSimpleStaticTls<type> var |
Definition at line 288 of file ncbithr.hpp.
#define DEFINE_CLASS_STATIC_FAST_MUTEX | ( | id | ) | NCBI_NS_NCBI::SSystemFastMutex id = STATIC_FAST_MUTEX_INITIALIZER |
Define fast mutex and initialize it.
Definition at line 504 of file ncbimtx.hpp.
#define DEFINE_CLASS_STATIC_MUTEX | ( | id | ) | NCBI_NS_NCBI::SSystemMutex id = STATIC_MUTEX_INITIALIZER |
Define mutex and initialize it.
Definition at line 520 of file ncbimtx.hpp.
#define DEFINE_STATIC_FAST_MUTEX | ( | id | ) | static NCBI_NS_NCBI::SSystemFastMutex id = STATIC_FAST_MUTEX_INITIALIZER |
Define static fast mutex and initialize it.
Definition at line 496 of file ncbimtx.hpp.
#define DEFINE_STATIC_MUTEX | ( | id | ) | static NCBI_NS_NCBI::SSystemMutex id = STATIC_MUTEX_INITIALIZER |
Define static mutex and initialize it.
Definition at line 512 of file ncbimtx.hpp.
#define INTERNAL_MUTEX_DEBUG |
Mutex debug setting.
Definition at line 93 of file ncbimtx.hpp.
Definition at line 143 of file ncbi_atomic_defs.h.
#define NCBI_COUNTER_ADD | ( | p, | |
d | |||
) | ((*p) += d) |
Definition at line 146 of file ncbi_atomic_defs.h.
#define NCBI_COUNTER_ASM_OK 1 |
Definition at line 85 of file ncbi_atomic_defs.h.
#define NCBI_COUNTER_UNSIGNED 1 |
Definition at line 144 of file ncbi_atomic_defs.h.
#define NCBI_COUNTER_USE_STD_ATOMIC 1 |
Definition at line 145 of file ncbi_atomic_defs.h.
#define NCBI_HAVE_CONDITIONAL_VARIABLE |
#define NCBI_NAMESPACE_MUTEX ncbi_namespace_mutex_mt |
Definition at line 147 of file ncbimtx.hpp.
#define NCBI_SCHED_SPIN_INIT | ( | ) | int spin_counter = 0 |
Definition at line 57 of file ncbi_atomic_defs.h.
#define NCBI_SCHED_SPIN_YIELD | ( | ) | if ( !(++spin_counter & 3) ) ::SwitchToThread() |
Definition at line 58 of file ncbi_atomic_defs.h.
#define NCBI_SCHED_YIELD | ( | ) | ::SwitchToThread() |
Definition at line 56 of file ncbi_atomic_defs.h.
#define NCBI_STATIC_TLS_VIA_SAFE_STATIC_REF 1 |
Definition at line 292 of file ncbithr.hpp.
#define NCBI_SWAP_POINTERS | ( | loc, | |
nv | |||
) | (InterlockedExchangePointer(loc, nv)) |
Definition at line 268 of file ncbi_atomic_defs.h.
#define STATIC_FAST_MUTEX_INITIALIZER { SYSTEM_MUTEX_INITIALIZER, NCBI_NS_NCBI::SSystemFastMutex::eMutexInitialized } |
Determine type of system mutex initialization.
Define static fast mutex initial value.
Definition at line 492 of file ncbimtx.hpp.
#define STATIC_MUTEX_INITIALIZER { STATIC_FAST_MUTEX_INITIALIZER, THREAD_SYSTEM_ID_INITIALIZER, 0 } |
Define static mutex initializer.
Definition at line 508 of file ncbimtx.hpp.
#define SYSTEM_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
Definition at line 120 of file ncbimtx.hpp.
#define THREAD_SYSTEM_ID_INITIALIZER 0 |
Use in defining initial value of system mutex.
Definition at line 164 of file ncbimtx.hpp.
typedef TFastMutexGuard CFastMutexGuard |
...and backward compatibility
Definition at line 391 of file ncbimtx.hpp.
typedef CGuard< CFastRWLock, SSimpleReadLock <CFastRWLock>, SSimpleReadUnlock<CFastRWLock> > CFastReadGuard |
Definition at line 1080 of file ncbimtx.hpp.
typedef CGuard< CFastRWLock, SSimpleWriteLock <CFastRWLock>, SSimpleWriteUnlock<CFastRWLock> > CFastWriteGuard |
Definition at line 1099 of file ncbimtx.hpp.
typedef TMutexGuard CMutexGuard |
...and backward compatibility
Definition at line 485 of file ncbimtx.hpp.
CNoMutex –.
Fake mutex that does not lock anything.
Allows to create template classes which use CMutex/CFastMutex/CNoMutex as an argument. In case of CNoMutex no real locking is performed.
Definition at line 824 of file ncbimtx.hpp.
typedef TReadLockGuard CReadLockGuard |
Definition at line 917 of file ncbimtx.hpp.
typedef CGuard<CSpinLock> CSpinGuard |
Definition at line 828 of file ncbimtx.hpp.
typedef TWriteLockGuard CWriteLockGuard |
Definition at line 935 of file ncbimtx.hpp.
typedef void(* CTls< TValue >::FCleanup) (TValue *value, void *cleanup_data) |
Define cleanup function type, FCleanup.
Definition at line 185 of file ncbithr.hpp.
typedef void(* CStaticTls< TValue >::FCleanup) (TValue *value, void *cleanup_data) |
Define cleanup function type, FCleanup.
Definition at line 327 of file ncbithr.hpp.
typedef void(* CTlsBase::FCleanupBase) (void *value, void *cleanup_data) |
Definition at line 72 of file ncbithr.hpp.
typedef void(* CStaticTls_Callbacks< TValue >::FUserCleanup) (void *ptr) |
Definition at line 300 of file ncbithr.hpp.
typedef void(* CStaticTls< TValue >::FUserCleanup) (void *ptr) |
User cleanup function type.
Definition at line 325 of file ncbithr.hpp.
|
private |
Definition at line 242 of file ncbithr.hpp.
typedef BV CLockVector< BV >::TBitVector |
Definition at line 60 of file lock_vector.hpp.
typedef CGuard<SSystemFastMutex> TFastMutexGuard |
typedefs for ease of use
Definition at line 388 of file ncbimtx.hpp.
typedef int CRWLock::TFlags |
binary OR of EFlags
Definition at line 961 of file ncbimtx.hpp.
|
private |
Definition at line 1350 of file ncbimtx.hpp.
typedef TThreadSystemID CThreadSystemID::TID |
Define a simpler alias for TThreadSystemID.
Definition at line 180 of file ncbimtx.hpp.
typedef unsigned int CThread::TID |
Get ID of current thread.
When not using native threads, but CThread only, the main thread is guaranteed to have zero id. With native threads the main thread may have a non-zero id and it's more reliable to use IsMain().
Definition at line 598 of file ncbithr.hpp.
typedef CSafeStaticLifeSpan CStaticTls< TValue >::TLifeSpan |
Definition at line 323 of file ncbithr.hpp.
|
private |
Definition at line 1283 of file ncbimtx.hpp.
typedef TLockVect CLockVectorGuard< TLockVect >::TLockVector |
Definition at line 101 of file lock_vector.hpp.
typedef CGuard<SSystemMutex> TMutexGuard |
typedefs for ease of use
Definition at line 482 of file ncbimtx.hpp.
typedef size_t TNCBIAtomicValue |
Define platform specific atomic-operations macros/values.
TNCBIAtomicValue "type" is defined based on facilities available for a compiler/platform. TNCBIAtomicValue is used in the CAtomicCounter class for defining the internal represntation of the counter.
Where possible NCBI_COUNTER_ADD is defined in terms of compiler/platform specific features, favoring inline assembly over standard library calls as function-call overhead can be appreciable, particularly on x86.
Definition at line 139 of file ncbi_atomic_defs.h.
|
private |
Definition at line 320 of file ncbithr.hpp.
Define Read Lock Guard.
Definition at line 680 of file ncbimtx.hpp.
typedef CMutexGuard CMutex::TReadLockGuard |
Define Read Lock Guard.
Definition at line 760 of file ncbimtx.hpp.
typedef CSpinGuard CSpinLock::TReadLockGuard |
Define Read Lock Guard.
Definition at line 849 of file ncbimtx.hpp.
typedef CGuard<CRWLock, SSimpleReadLock<CRWLock> > TReadLockGuard |
Definition at line 916 of file ncbimtx.hpp.
Define Read Lock Guard.
Definition at line 970 of file ncbimtx.hpp.
Definition at line 1137 of file ncbimtx.hpp.
typedef int CThread::TRunMode |
Bitwise OR'd flags for thread creation passed to Run().
Definition at line 558 of file ncbithr.hpp.
Types of smart references to IRWLockHolder_Listener.
Definition at line 1202 of file ncbimtx.hpp.
Definition at line 1203 of file ncbimtx.hpp.
typedef CRef<CRWLockHolder> TRWLockHolderRef |
Type that should be always used to store pointers to CRWLockHolder.
Definition at line 1300 of file ncbimtx.hpp.
typedef pthread_mutex_t TSystemMutex |
Define a platform independent system mutex.
Definition at line 119 of file ncbimtx.hpp.
typedef pthread_t TThreadHandle |
Define platform-dependent thread handle type.
Definition at line 92 of file ncbithr_conf.hpp.
typedef pthread_t TThreadSystemID |
Define platform-dependent thread ID type.
Definition at line 95 of file ncbithr_conf.hpp.
typedef pthread_key_t TTlsKey |
Define internal TLS key type.
Definition at line 89 of file ncbithr_conf.hpp.
|
private |
Definition at line 506 of file ncbithr.hpp.
typedef void* TWrapperArg |
Define platform-dependent argument wrapper.
Definition at line 101 of file ncbithr_conf.hpp.
typedef void* TWrapperRes |
Define platform-dependent result wrapper.
Definition at line 98 of file ncbithr_conf.hpp.
Define Write Lock Guard.
Definition at line 683 of file ncbimtx.hpp.
typedef CMutexGuard CMutex::TWriteLockGuard |
Define Write Lock Guard.
Definition at line 763 of file ncbimtx.hpp.
typedef CSpinGuard CSpinLock::TWriteLockGuard |
Define Write Lock Guard.
Definition at line 851 of file ncbimtx.hpp.
typedef CGuard<CRWLock, SSimpleWriteLock<CRWLock> > TWriteLockGuard |
Definition at line 934 of file ncbimtx.hpp.
Define Write Lock Guard.
Definition at line 973 of file ncbimtx.hpp.
Definition at line 1138 of file ncbimtx.hpp.
typedef V CSimpleStaticTls< V >::value_type |
Definition at line 278 of file ncbithr.hpp.
|
private |
Enumerator | |
---|---|
kWriteLockValue | Number in lock count showing that write lock is acquired. |
Definition at line 1157 of file ncbimtx.hpp.
Flag telling which code has called TLS cleanup.
Enumerator | |
---|---|
eCleanup_Toolkit | Cleanup is performed by CThread. |
eCleanup_Native | Cleanup is performed by thread_local destructor. |
Definition at line 84 of file ncbithr.hpp.
Error types that a mutex can generate.
Enumerator | |
---|---|
eLock | Lock error. |
eUnlock | Unlock error. |
eTryLock | Attempted lock error. |
eOwner | Not owned error. |
eUninitialized | Uninitialized error. |
Definition at line 233 of file ncbimtx.hpp.
Error types that a condition variable can generate.
Definition at line 1528 of file ncbimtx.hpp.
Enumerator | |
---|---|
eRunError | Failed to run thread. |
eControlError | Failed to control thread's state. |
eOther | Other thread errors. |
Definition at line 695 of file ncbithr.hpp.
enum CRWLock::EFlags |
Flags (passed at construction time) for fine-tuning lock behavior.
Enumerator | |
---|---|
fFavorWriters | Forbid further readers from acquiring the lock if any writers are waiting for it, to keep would-be writers from starving. |
Definition at line 956 of file ncbimtx.hpp.
|
private |
Enumerator | |
---|---|
fTrackReaders | Keep track of which threads have read locks. |
Definition at line 1039 of file ncbimtx.hpp.
This is for condition variables.
Enumerator | |
---|---|
eNormal | |
ePseudo | Modify object data and call system. Modify object data, but do not call system |
Definition at line 287 of file ncbimtx.hpp.
Initialization flag values.
Enumerator | |
---|---|
eMutexUninitialized | Uninitialized value. |
eMutexInitialized | Magic initialized value,. |
Definition at line 280 of file ncbimtx.hpp.
Flag indicating if cleanup function should be called when using native threads rather than CThread.
Native threads may perform cleanup later than CThread, so that some resources (like static variables) may be already destroyed. To prevent failures the default mode is eSkipCleanup.
Enumerator | |
---|---|
eDoCleanup | |
eSkipCleanup |
Definition at line 78 of file ncbithr.hpp.
enum CThread::ERunMode |
Which mode should the thread run in.
Definition at line 539 of file ncbithr.hpp.
enum ERWLockType |
Type of locking provided by CYieldingRWLock.
Enumerator | |
---|---|
eReadLock | |
eWriteLock |
Definition at line 1179 of file ncbimtx.hpp.
TRWLockHolderRef CYieldingRWLock::AcquireLock | ( | ERWLockType | lock_type | ) |
General method to request read or write lock.
Definition at line 2241 of file ncbimtx.cpp.
References IRWLockHolder_Factory::CreateHolder(), eWriteLock, CYieldingRWLock::m_Factory, CYieldingRWLock::m_Locks, CYieldingRWLock::m_LockWaits, and CYieldingRWLock::m_ObjLock.
TRWLockHolderRef CYieldingRWLock::AcquireReadLock | ( | void | ) |
Read lock.
Method returns immediately no matter if lock is granted or not. If lock is not granted then request for lock is remembered and will be granted later unless CRWLockHolder::ReleaseLock() is called (or object is deleted).
TRWLockHolderRef CYieldingRWLock::AcquireWriteLock | ( | void | ) |
Write lock.
Method returns immediately no matter if lock is granted or not. If lock is not granted then request for lock is remembered and will be granted later unless CRWLockHolder::ReleaseLock() is called (or object is deleted).
void CRWLockHolder::AddListener | ( | IRWLockHolder_Listener * | listener | ) |
Add object keeping track of holder state changes.
CConditionVariable::CConditionVariable | ( | void | ) |
Definition at line 2364 of file ncbimtx.cpp.
References NCBI_THROW, and NULL.
|
private |
Private copy constructor to disallow initialization.
CFastMutex::CFastMutex | ( | void | ) |
Constructor.
Creates mutex handle.
|
private |
CFastRWLock::CFastRWLock | ( | void | ) |
void ncbi_namespace_mutex_mt::SSystemFastMutex::CheckInitialized | ( | void | ) | const |
Check initialized value of mutex.
|
inline |
Definition at line 306 of file ncbithr.hpp.
Referenced by CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::sx_SelfCleanup().
|
staticprivate |
Definition at line 201 of file ncbithr.cpp.
References CTlsBase::CleanupTlsData(), and data.
Referenced by CTlsBase::x_CleanupThreadCallback(), and CTlsBase::x_DeleteTlsData().
|
staticprivate |
Definition at line 191 of file ncbithr.cpp.
References data, CTlsBase::eCleanup_Native, CTlsBase::eSkipCleanup, CTlsBase::STlsData::m_CleanupData, CTlsBase::STlsData::m_CleanupFunc, CTlsBase::STlsData::m_Native, and CTlsBase::STlsData::m_Value.
Referenced by CTlsBase::CleanupAndDeleteTlsData(), and CTlsBase::x_SetValue().
void CUsedTlsBases::ClearAll | ( | CTlsBase::ECleanupMode | mode = CTlsBase::eCleanup_Toolkit | ) |
The function is called before thread termination to cleanup data stored in the TLS.
Definition at line 82 of file ncbithr.cpp.
References set< Key, Compare >::clear(), CSafeStatic< T, Callbacks >::Get(), CTlsBase::m_AutoDestroy, CUsedTlsBases::m_UsedTls, NON_CONST_ITERATE, NULL, CObject::Referenced(), CObject::RemoveReference(), CUsedTlsBases::sm_UsedTlsBases, and CTlsBase::x_DeleteTlsData().
Referenced by s_CleanupMainUsedTlsBases().
|
static |
Clear used TLS-es for the current thread.
Definition at line 174 of file ncbithr.cpp.
References CStaticTls< TValue >::GetValue(), and CUsedTlsBases::sm_UsedTlsBases.
Referenced by CThread::Wrapper(), and SNativeThreadTlsCleanup::~SNativeThreadTlsCleanup().
CLockVector< BV >::CLockVector |
Definition at line 281 of file lock_vector.hpp.
|
private |
|
private |
CLockVectorGuard< TLockVect >::CLockVectorGuard | ( | TLockVector & | lvect, |
unsigned | id, | ||
unsigned | timeout_ms | ||
) |
Construct and lock.
lvect | Lock vector storing all locks |
id | Object Id we are locking |
timeout_ms | Timeout in milliseconds for how long lock makes attempts to acquire the id. If cannot lock it throws an exception. |
Definition at line 182 of file lock_vector.hpp.
References _ASSERT, and CLockVectorGuard< TLockVect >::DoLock().
CLockVectorGuard< TLockVect >::CLockVectorGuard | ( | TLockVector & | lvect, |
unsigned | timeout_ms | ||
) |
Construct without locking.
Definition at line 170 of file lock_vector.hpp.
CMutex::CMutex | ( | void | ) |
Constructor.
|
inline |
Definition at line 303 of file ncbithr.hpp.
|
pure virtual |
Obtain new CRWLockHolder object for given CYieldingRWLock and necessary lock type.
Implemented in CRWLockHolder_Pool.
Referenced by CYieldingRWLock::AcquireLock().
CRWLock::CRWLock | ( | TFlags | flags = 0 | ) |
Constructor.
Definition at line 659 of file ncbimtx.cpp.
References CRWLock::fFavorWriters, CRWLock::fTrackReaders, CRWLock::m_Flags, and CRWLock::m_Readers.
|
private |
CRWLockHolder::CRWLockHolder | ( | IRWLockHolder_Factory * | factory | ) |
Create lock holder bound to given object factory.
|
private |
Private copy constructor to disallow initialization.
Constructor.
int_count | The initial value of the semaphore. |
max_count | Maximum value that semaphore value can be incremented to. NOTE: On Windows max_count can not be greater than LONG_MAX. |
Definition at line 1696 of file ncbimtx.cpp.
References SSemaphore::cond, SSemaphore::count, ERR_POST, Error(), CSemaphore::m_Sem, SSemaphore::max_count, min(), SSemaphore::mutex, NULL, SSemaphore::wait_count, xncbi_Validate, and xncbi_ValidatePthread.
CSpinLock::CSpinLock | ( | void | ) |
|
inline |
Definition at line 329 of file ncbithr.hpp.
|
inline |
Definition at line 301 of file ncbithr.hpp.
CThread::CThread | ( | void | ) |
Constructor.
Must be allocated in the heap only!.
Definition at line 645 of file ncbithr.cpp.
References CObject::DoDeleteThisObject().
Definition at line 168 of file ncbithr.hpp.
|
inlineprotected |
Constructor.
Definition at line 91 of file ncbithr.hpp.
|
private |
CUsedTlsBases::CUsedTlsBases | ( | void | ) |
Definition at line 72 of file ncbithr.cpp.
Referenced by CUsedTlsBases::GetUsedTlsBases().
CYieldingRWLock::CYieldingRWLock | ( | IRWLockHolder_Factory * | factory = NULL | ) |
Create read/write lock with custom holders factory.
By default (if factory == NULL) pooling of CRWLockHolder will be used.
Definition at line 2208 of file ncbimtx.cpp.
References eReadLock, eWriteLock, CYieldingRWLock::m_Factory, CYieldingRWLock::m_Locks, and s_RWHolderPool.
|
inlinestatic |
Definition at line 148 of file ncbithr.hpp.
References rapidjson::value.
|
pure virtual |
Free unnecessary (and unreferenced by anybody) CRWLockHolder object.
Implemented in CRWLockHolder_Pool.
Referenced by CRWLockHolder::DeleteThis().
|
privatevirtual |
"Delete" this holder after last reference was removed.
Actually deletes using factory's DeleteHolder().
Reimplemented from CObject.
Definition at line 2112 of file ncbimtx.cpp.
References IRWLockHolder_Factory::DeleteHolder(), and CRWLockHolder::m_Factory.
void CUsedTlsBases::Deregister | ( | CTlsBase * | tls | ) |
Definition at line 122 of file ncbithr.cpp.
References set< Key, Compare >::erase(), CTlsBase::m_AutoDestroy, CUsedTlsBases::m_UsedTls, CObject::RemoveReference(), and xncbi_VerifyAndErrorReport.
Referenced by CTlsBase::x_Reset().
void SSystemFastMutex::Destroy | ( | void | ) |
void SSystemMutex::Destroy | ( | void | ) |
void SSystemFastMutex::DestroyHandle | ( | void | ) |
Destroy mutex handle.
Must be called only once.
Definition at line 168 of file ncbimtx.cpp.
References WRITE_MUTEX_EVENT, and xncbi_VerifyAndErrorReport.
void CThread::Detach | ( | void | ) |
Inform the thread that user does not need to wait for its termination.
The thread object will be destroyed by Exit(). If the thread has already been terminated by Exit, Detach() will also schedule the thread object for destruction. NOTE: it is no more safe to use this thread object after Detach(), unless there are still CRef<> based references to it!
Definition at line 833 of file ncbithr.cpp.
References CThread::m_Handle, CThread::m_IsDetached, CThread::m_IsRun, CThread::m_IsTerminated, CThread::m_SelfRef, NCBI_THREAD_VALIDATE, NULL, and CRef< C, Locker >::Reset().
Referenced by CPoolOfThreads< CRef< CStdRequest > >::Register().
|
inline |
Discard thread local storage.
Schedule the TLS to be destroyed as soon as there are no CRef to it left.
Definition at line 223 of file ncbithr.hpp.
bool CThread::Discard | ( | void | ) |
If the thread has not been Run() yet, then schedule the thread object for destruction, and return TRUE.
Otherwise, do nothing, and return FALSE.
Definition at line 923 of file ncbithr.cpp.
References CThread::m_IsRun, CThread::m_SelfRef, and CRef< C, Locker >::Reset().
Referenced by CAsyncTaskProcessor< TTask >::CExecutor::SThread::Stop().
void CLockVectorGuard< TLockVect >::DoLock |
Lock acquisition.
Definition at line 208 of file lock_vector.hpp.
References _ASSERT, i, msg(), NCBI_THROW, SleepMilliSec(), and NStr::UIntToString().
Referenced by CLockVectorGuard< TLockVect >::CLockVectorGuard().
|
static |
Cancel current thread.
If the thread is detached, then schedule the thread object for destruction. Cancellation is performed by throwing an exception of type CExitThreadException to allow destruction of all objects in thread's stack, so Exit() method shell not be called from any destructor.
Definition at line 906 of file ncbithr.cpp.
References CThread::GetCurrentThread(), CThread::m_ExitData, and NCBI_THREAD_VALIDATE.
Referenced by CResolveRequestFatal::Process(), CFatalRequest_ForServer::Process(), CFatalRequest::Process(), and CIStreamIteratorThread_Base< TRoot, TObject >::SetObject().
void CLockVector< BV >::FreeUnusedMem |
Reclaim unused memory.
Definition at line 315 of file lock_vector.hpp.
Referenced by CBDB_Cache::Purge().
|
inlinestatic |
Definition at line 245 of file ncbithr.hpp.
References A.
Referenced by CSimpleStaticTls< V >::operator value_type().
|
inlinestatic |
Definition at line 253 of file ncbithr.hpp.
References A.
|
inlinestatic |
Get the current thread ID.
Definition at line 185 of file ncbimtx.hpp.
References GetCurrentThreadSystemID(), and CThreadSystemID::m_ID.
|
static |
Get current CThread object (or NULL, if main thread)
Definition at line 508 of file ncbithr.cpp.
Referenced by CThread::Exit(), and CPrefetchManager::IsActive().
|
inlinestatic |
Get the current thread ID.
Definition at line 152 of file ncbimtx.hpp.
Referenced by CFileIO::CreateTemporary(), CThreadSystemID::GetCurrent(), CThread::GetSystemID(), ncbi_namespace_mutex_mt::SSystemMutex::Lock(), CJaegerTracer::OnRequestStart(), COpentelemetryTracer::OnRequestStart(), CRWLock::ReadLock(), s_GetThreadId(), ncbi_namespace_mutex_mt::SSystemMutex::TryLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), ncbi_namespace_mutex_mt::SSystemMutex::Unlock(), CRWLock::Unlock(), CConditionVariable::WaitForSignal(), CRWLock::WriteLock(), CSyncQueue< Type, Container, Traits >::x_GuardedLock(), CSyncQueue< Type, Container, Traits >::x_IsGuarded(), and CRWLock::x_MayAcquireForReading().
|
overridevirtual |
Translate from the error code value to its string representation.
Reimplemented from CCoreException.
Definition at line 500 of file ncbimtx.cpp.
References CMutexException::eLock, CMutexException::eOwner, CMutexException::eTryLock, CMutexException::eUninitialized, CMutexException::eUnlock, CCoreException::GetErrCode(), and CException::GetErrCodeString().
|
overridevirtual |
Translate from the error code value to its string representation.
Reimplemented from CCoreException.
Definition at line 2638 of file ncbimtx.cpp.
References CConditionVariableException::eInvalidValue, CConditionVariableException::eMutexDifferent, CConditionVariableException::eMutexLockCount, CConditionVariableException::eMutexOwner, CConditionVariableException::eUnsupported, CCoreException::GetErrCode(), and CException::GetErrCodeString().
|
overridevirtual |
Translate from the error code value to its string representation.
Definition at line 994 of file ncbithr.cpp.
References CThreadException::eControlError, CThreadException::eOther, CThreadException::eRunError, and CException::GetErrCodeString().
IRWLockHolder_Factory* CRWLockHolder::GetFactory | ( | void | ) | const |
Get factory which this object was created from.
|
inlineprivate |
Get handle - Unix version.
Also used by CRWLock.
Definition at line 702 of file ncbimtx.hpp.
References CFastMutex::m_Mutex.
|
inline |
Get BLOB id.
Definition at line 135 of file lock_vector.hpp.
Referenced by CBDB_Cache::GetWriteStream(), and CBDB_Cache::x_Store().
ERWLockType CRWLockHolder::GetLockType | ( | void | ) | const |
Get type of lock held.
|
inline |
Definition at line 155 of file lock_vector.hpp.
CYieldingRWLock* CRWLockHolder::GetRWLock | ( | void | ) | const |
Get lock object that is locked by this holder.
|
static |
Definition at line 515 of file ncbithr.cpp.
References CThread::InitializeMainThreadId(), kMainThreadId, sm_MainThreadIdInitialized, and sx_GetNextThreadId().
Referenced by CBlastDbDataLoader::GetLoaderNameFromArgs(), CThreadLocalTransactional::GetTransaction(), CIgBlastnApp::CIgWorker::Main(), CIgBlastnApp::CIgFormatter::Main(), CRandom::Randomize(), CThreadLocalTransactional::RemoveTransaction(), s_CountBlastDbDataLoaders(), s_GetThreadId(), sAssertMainThread(), CBlastNode::SetDataLoaderPrefix(), CThreadLocalTransactional::SetTransaction(), CSeqDBImpl::x_GetCacheID(), CSeqDBVol::x_GetFilteredHeader(), CAsnCache_DataLoader::x_GetIndex(), CSeqDBVol::x_GetTaxonomy(), and SDiagMessage::x_OldWrite().
|
static |
Get system ID of the current thread - for internal use only.
The ID is unique only while the thread is running and may be re-used by another thread later.
Definition at line 946 of file ncbithr.cpp.
References GetCurrentThreadSystemID().
Referenced by CTSE_LoadLock::ReleaseLoadLock(), and CDataSource::x_SetLoadLock().
|
inlineprotected |
Definition at line 778 of file ncbithr.hpp.
References CThread::m_Handle.
|
inlinestatic |
Get total amount of threads This amount does not contain main thread.
Definition at line 785 of file ncbithr.hpp.
References CThread::sm_ThreadsCount.
Referenced by CSyncQueue_DefaultTraits::IsUsedConcurrently(), s_Daemonize(), and CSafeStaticGuard::~CSafeStaticGuard().
|
inline |
Definition at line 156 of file lock_vector.hpp.
|
static |
Get the list of used TLS-es for the current thread.
Definition at line 151 of file ncbithr.cpp.
References CUsedTlsBases::CUsedTlsBases(), CTlsBase::eDoCleanup, CStaticTls< TValue >::GetValue(), CThread::IsMain(), s_CleanupUsedTlsBases(), s_MainUsedTlsBases, CStaticTls< TValue >::SetValue(), and CUsedTlsBases::sm_UsedTlsBases.
Referenced by CTlsBase::x_Reset(), and CTlsBase::x_SetValue().
|
inline |
Definition at line 335 of file ncbithr.hpp.
Referenced by CUsedTlsBases::ClearAllCurrentThread(), GetCTLExceptionStorage(), CDiagContextThreadData::GetThreadData(), and CUsedTlsBases::GetUsedTlsBases().
|
inline |
Get the pointer previously stored by SetValue().
Return 0 if no value has been stored, or if Reset() was last called.
Definition at line 179 of file ncbithr.hpp.
Referenced by CCgiApplication::x_GetProcessor(), CCgiApplication::x_GetProcessorOrNull(), CLDS2_UrlHandler_File::x_GetStreamCache(), and CCgiApplication::x_IsSetProcessor().
void CRWLockHolder::Init | ( | CYieldingRWLock * | lock, |
ERWLockType | typ | ||
) |
Initialize holder for given CYieldingRWLock and necessary lock type.
Method is for use only inside IRWLockHolder_Factory implementation
Referenced by CRWLockHolder_Pool::CreateHolder().
|
static |
Init TLS, call before creating thread.
Definition at line 168 of file ncbithr.cpp.
References CSafeStatic< T, Callbacks >::Get(), and CUsedTlsBases::sm_UsedTlsBases.
Referenced by CThread::Run().
void SSystemFastMutex::InitializeDynamic | ( | void | ) |
Initialize dynamic mutex.
Initialize mutex if it located in heap or stack. This must be called only once. Do not count on zeroed memory values for initializing mutex values.
Definition at line 207 of file ncbimtx.cpp.
void ncbi_namespace_mutex_mt::SSystemMutex::InitializeDynamic | ( | void | ) |
Initialize dynamic mutex.
Initialize mutex if it located in heap or stack. This must be called only once. Do not count on zeroed memory values for initializing mutex values.
void SSystemFastMutex::InitializeHandle | ( | void | ) |
Initialize mutex handle.
Must be called only once.
Definition at line 136 of file ncbimtx.cpp.
References FALSE, NULL, WRITE_MUTEX_EVENT, xncbi_ValidateAndErrnoReport, and xncbi_ValidatePthread.
|
static |
Initialize main thread's TID.
The function must be called from the main thread if the application is using non-toolkit threads. Otherwise getting thread id of a native thread will return zero.
Definition at line 482 of file ncbithr.cpp.
References _ASSERT, ERR_POST, kMainThreadId, sm_MainThreadIdInitialized, and sx_MainThreadId.
Referenced by CNcbiApplicationAPI::CNcbiApplicationAPI(), CThreadedApp::CThreadedApp(), CThread::GetSelf(), CThread::IsMain(), and main().
void SSystemFastMutex::InitializeStatic | ( | void | ) |
Initialize static mutex.
Must be called only once.
Definition at line 186 of file ncbimtx.cpp.
References xncbi_Validate.
void ncbi_namespace_mutex_mt::SSystemMutex::InitializeStatic | ( | void | ) |
Initialize static mutex.
Must be called only once.
|
inline |
Definition at line 209 of file ncbimtx.hpp.
References CThreadSystemID::m_ID.
Check if the application is exiting (entered the destructor).
Recommended to be used as while() condition by infinite threads to stop them properly on exit.
Definition at line 629 of file ncbithr.hpp.
References CThread::sm_IsExiting.
bool ncbi_namespace_mutex_mt::SSystemFastMutex::IsInitialized | ( | void | ) | const |
Check if mutex is initialized.
bool ncbi_namespace_mutex_mt::SSystemMutex::IsInitialized | ( | void | ) | const |
Check if mutex is initialized.
bool CLockVector< BV >::IsLocked | ( | unsigned | id | ) | const |
Check if id is locked or not.
Definition at line 322 of file lock_vector.hpp.
Referenced by CBDB_Cache::IsLocked().
|
static |
Definition at line 537 of file ncbithr.cpp.
References CThread::InitializeMainThreadId(), sm_MainThreadIdInitialized, and sx_GetMainThreadId().
Referenced by CDiagContextThreadData::GetThreadData(), CUsedTlsBases::GetUsedTlsBases(), CDiagContext::IsMainThreadDataInitialized(), CDiagContext::sx_ThreadDataTlsCleanup(), CThread::WaitForAllThreads(), CThread::Wrapper(), and SNativeThreadTlsCleanup::~SNativeThreadTlsCleanup().
|
inline |
Definition at line 213 of file ncbimtx.hpp.
References CThreadSystemID::m_ID.
|
static |
Definition at line 2358 of file ncbimtx.cpp.
|
inline |
Check if the thread has been terminated.
Definition at line 593 of file ncbithr.hpp.
References CThread::m_IsTerminated.
bool ncbi_namespace_mutex_mt::SSystemFastMutex::IsUninitialized | ( | void | ) | const |
Check if mutex is un-initialized.
bool ncbi_namespace_mutex_mt::SSystemMutex::IsUninitialized | ( | void | ) | const |
Check if mutex is un-initialized.
void CThread::Join | ( | void ** | exit_data = 0 | ) |
Wait for the thread termination.
The thread object will be scheduled for destruction right here, inside Join(). Only one call to Join() is allowed.
Definition at line 863 of file ncbithr.cpp.
References CThread::m_ExitData, CThread::m_Handle, CThread::m_IsDetached, CThread::m_IsJoined, CThread::m_IsRun, CThread::m_SelfRef, NCBI_THREAD_VALIDATE, NULL, and CRef< C, Locker >::Reset().
Referenced by CBlastAsyncFormatThread::Join(), CNCMMCentral::PrepareToStop(), CMergeyApp::Run(), CMagicBlastApp::Run(), SGridWorkerNodeImpl::Run(), CSchedulerEngine::ShutDown(), CAsyncTaskProcessor< TTask >::CExecutor::SThread::Stop(), CIStreamIteratorThread_Base< TRoot, TObject >::Stop(), CAsyncDiagThread::Stop(), CBDB_Env::StopBackgroundWriterThread(), CQueueDataBase::StopExecutionWatcherThread(), CQueueDataBase::StopNotifThread(), CBDB_Cache::StopPurgeThread(), CQueueDataBase::StopPurgeThread(), CQueueDataBase::StopServiceThread(), CNetStorageServer::StopServiceThread(), CMMAligner::x_DoSubmatrix(), CNSTDatabase::~CNSTDatabase(), CWGSClient::~CWGSClient(), CWGSDataLoader_Impl::~CWGSDataLoader_Impl(), and SNetScheduleAPIImpl::~SNetScheduleAPIImpl().
void SSystemFastMutex::Lock | ( | ELockSemantics | lock = eNormal | ) |
Acquire mutex for the current thread with no nesting checks.
Definition at line 256 of file ncbimtx.cpp.
References WRITE_MUTEX_EVENT.
void SSystemMutex::Lock | ( | SSystemFastMutex::ELockSemantics | lock = SSystemFastMutex::eNormal | ) |
Acquire mutex for the current thread.
Definition at line 352 of file ncbimtx.cpp.
References assert, count, and GetCurrentThreadSystemID().
void CLockVectorGuard< TLockVect >::Lock | ( | unsigned | id | ) |
Acquire lock.
Definition at line 247 of file lock_vector.hpp.
Referenced by CBDB_Cache::BlobCheckIn().
void CFastMutex::Lock | ( | void | ) |
Acquire mutex for the current thread with no nesting checks.
Referenced by CRtProfiler::AddMarkerMT(), CRtProfiler::AddUserKVMT(), CRtProfiler::AsStringMT(), BlastLockHandler(), CBlastAsyncFormatThread::Finalize(), CServer_ConnectionPool::GetListenerPorts(), CServer_ConnectionPool::GetPollAndTimerVec(), CBDB_Cache::Lock(), CDBConnectionFactory::CServiceInfo::Lock(), CBlastAsyncFormatThread::Main(), CBlastKmerThread::Main(), CBlastAsyncFormatThread::QueueResults(), CFastRWLock::ReadLock(), CServer_ConnectionPool::RemoveListener(), CServer_ConnectionPool::SetAllActive(), CRtProfiler::StartMT(), CRtProfiler::StopMT(), CThreadGroup::SyncPoint(), CFastRWLock::WriteLock(), CNCMMCentral::x_DoBackgroundWork(), and CNSTDBConnectionThread::x_RestoreConnection().
void CMutex::Lock | ( | void | ) |
Lock mutex.
Operation:
Referenced by CGBProject::Lock(), CAppJobDispatcher::Lock(), CSafeStaticPtr_Base::Lock(), and CInfoManager::x_LockInfoMutex().
void CSpinLock::Lock | ( | void | ) |
Lock the mutex.
Definition at line 2326 of file ncbimtx.cpp.
References CSpinLock::m_Value, NCBI_SCHED_YIELD, NULL, and SwapPointers().
Referenced by CObjPool< CRWLockHolder, THolderPoolFactory >::Clear(), CObjPool< CRWLockHolder, THolderPoolFactory >::Get(), CObjPool< CRWLockHolder, THolderPoolFactory >::Return(), CRWLockHolder::x_OnLockAcquired(), and CRWLockHolder::x_OnLockReleased().
|
protectedpure virtual |
Derived (user-created) class must provide a real thread function.
Implemented in CBlastNode, CIStreamStdIteratorThread< TRoot, TObject >, CIStreamObjectIteratorThread< TRoot, TObject >, CThreadPool_ServiceThread, CScheduler_ExecThread_Impl, CSeqDBDemo_Thread, CTotalRangeThread, CMTTestThread, CSchedulerEngineThread, CSQLITE_AsyncWritesThread, CInGroupThread, CTestThread, CAsyncDiagThread, CWorkerNodeIdleThread, CGridControlThread, CNetStorageServiceThread, CNSTDBConnectionThread, CJobQueueExecutionWatcherThread, CJobQueueCleanerThread, CServiceThread, CGetJobNotificationThread, CMagicBlastThread, CIgBlastnApp::CIgFormatter, CIgBlastnApp::CIgWorker, CAsyncTaskProcessor< TTask >::CExecutor::SThread, CTblastnNode, CRPSTBlastnNode, CRPSBlastNode, CBlastxNode, CBlastpNode, CBlastnNode, CSearch< LEGACY, NHITS >, CVDBThread, CTestThread, CSeqDBTest3Thread, CSeqDBTest2Thread, CSeqDBTestThread, CDLTest2Thread, CDLTestThread, CHspStreamWriteThread, CBlastKmerThread, CRPSThread, CPrelimSearchThread, CMergeOutputThread, CMergeTreeThread, CThreadInPool< TRequest >, CThreadInPool< CRef< CStdRequest > >, CThreadPool_Thread, CThreadNonStop, CIStreamIteratorThread_Base< TRoot, TObject >, CPrefetchThreadOld, CAssemblyCache::CWorkerThread, CConnTestThread, CThreadInPool_ForServer, CBlastAsyncFormatThread, CLocalAdapterThread, CJobCommitterThread, CGridCleanupThread, SNetScheduleNotificationThread, CMainLoopThread, CAsn2AsnThread, CNWAlignerThread_Align, CThreadDoSM, CThreadRunOnTop, and CSQLITE3_Cache::CWriterThread.
Referenced by CThread::Wrapper().
CConditionVariableException::NCBI_EXCEPTION_DEFAULT | ( | CConditionVariableException | , |
CCoreException | |||
) |
CMutexException::NCBI_EXCEPTION_DEFAULT | ( | CMutexException | , |
CCoreException | |||
) |
CThreadException::NCBI_EXCEPTION_DEFAULT | ( | CThreadException | , |
CException | |||
) |
|
inline |
Definition at line 65 of file ncbiatomic.h.
References a, location, NCBI_SCHED_SPIN_INIT, NCBI_SCHED_SPIN_YIELD, NCBI_SWAP_POINTERS, and tmp.
Referenced by SwapPointers().
|
protectedvirtual |
Override this to execute finalization code.
Unlike destructor, this code will be executed before thread termination and as a part of the thread.
Reimplemented in CSeqDBDemo_Thread, CTestThread, CWorkerNodeIdleThread, CGridControlThread, CIgBlastnApp::CIgFormatter, CIgBlastnApp::CIgWorker, CSearch< LEGACY, NHITS >, CHspStreamWriteThread, CThreadInPool< TRequest >, CThreadInPool< CRef< CStdRequest > >, CThreadPool_Thread, CNWAlignerThread_Align, CThreadDoSM, and CThreadRunOnTop.
Definition at line 940 of file ncbithr.cpp.
Referenced by CGridControlThread::OnExit(), and CThread::Wrapper().
|
pure virtual |
Callback called when lock represented by CRWLockHolder is acquired.
|
pure virtual |
Callback called when lock represented by CRWLockHolder is released.
CFastMutex::operator SSystemFastMutex & | ( | void | ) |
Get SSystemFastMutex.
CMutex::operator SSystemMutex & | ( | void | ) |
Get SSystemMutex.
|
inline |
Getter - returns value stored in TLS.
Definition at line 280 of file ncbithr.hpp.
References CSimpleStaticTls< V >::SCaster< A >::FromVoidP(), and CSimpleStaticTls< V >::x_GetKey().
|
inline |
Non-equality operator for thread ID.
Definition at line 199 of file ncbimtx.hpp.
References CThreadSystemID::m_ID.
|
inline |
Definition at line 910 of file ncbimtx.hpp.
|
inline |
Definition at line 928 of file ncbimtx.hpp.
|
inline |
Definition at line 1072 of file ncbimtx.hpp.
|
inline |
Definition at line 1091 of file ncbimtx.hpp.
|
private |
Private assignment operator to disallow assignment.
|
private |
|
private |
|
private |
Private assignment operator to disallow assignment.
Private assignment operator to disallow assignment.
|
private |
|
private |
Private assignment operator to disallow assignment.
|
private |
|
inline |
Setter - changes value stored in TLS.
Definition at line 284 of file ncbithr.hpp.
References CSimpleStaticTls< V >::x_GetKey().
|
inline |
Equality operator for thread ID.
Definition at line 193 of file ncbimtx.hpp.
References CThreadSystemID::m_ID.
void CSemaphore::Post | ( | unsigned int | count = 1 | ) |
Increment the semaphore by "count".
Do nothing and throw an exception if counter would exceed "max_count".
Definition at line 1971 of file ncbimtx.cpp.
References SSemaphore::cond, SSemaphore::count, count, kMax_UInt, CSemaphore::m_Sem, SSemaphore::max_count, SSemaphore::mutex, NULL, SSemaphore::wait_count, xncbi_Validate, xncbi_ValidateAndErrnoReport, and xncbi_ValidatePthread.
Referenced by CThreadPool_Impl::Abort(), CPrefetchTokenOld_Impl::AddResolvedId(), CSchedulerEngine::CancelJob(), CBlastAsyncFormatThread::Finalize(), CTestThread::GlobalSyncPoint(), CThreadGroup::Go(), SServerNotifications::InterruptWait(), SGridWorkerNodeImpl::LeaveExclusiveMode(), CGridCleanupThread::Main(), CBlastAsyncFormatThread::Main(), CIgBlastnApp::CIgWorker::Main(), CAsyncDiagThread::Main(), impl::CDriverContext::MakePooledConnection(), CPSGL_QueueGuard::MarkAsFinished(), CIStreamIteratorThread_Base< TRoot, TObject >::Next(), CPrefetchTokenOld_Impl::NextBioseqHandle(), CScheduler_ExecThread_Impl::OnNextExecutionTimeChange(), CPSGL_RequestTracker::OnStatusChange(), CBlastAsyncFormatThread::QueueResults(), SServerNotifications::RegisterServer(), CPrefetchTokenOld_Impl::RemoveTokenReference(), CThreadNonStop::RequestDoJob(), CWorkerNodeIdleThread::RequestShutdown(), CThreadNonStop::RequestStop(), CGetJobNotificationThread::RequestStop(), CJobQueueCleanerThread::RequestStop(), CJobQueueExecutionWatcherThread::RequestStop(), CWorkerNodeIdleThread::Schedule(), CIStreamIteratorThread_Base< TRoot, TObject >::SetObject(), CSchedulerEngine::ShutDown(), CSchedulerEngine::StartJob(), CIStreamIteratorThread_Base< TRoot, TObject >::Stop(), CAsyncDiagThread::Stop(), CScheduler_ExecThread_Impl::Stop(), CBDB_Cache::StopPurge(), CWorkerNodeIdleThread::Suspend(), CThreadGroup::SyncPoint(), CThreadPool_Impl::TaskFinished(), CThreadGroup::ThreadComplete(), CThreadPool_Impl::ThreadStateChanged(), SGridWorkerNodeImpl::WaitForExclusiveJobToFinish(), CJobCommitterThread::WakeUp(), CGetJobNotificationThread::WakeUp(), CNSTDBConnectionThread::Wakeup(), CThreadPool_ThreadImpl::WakeUp(), CThreadPool_ServiceThread::WakeUp(), impl::CDriverContext::x_Recycle(), CReader::x_ReleaseClosedConnection(), CReader::x_ReleaseConnection(), and CPSGL_RequestTracker::CCallbackGuard::~CCallbackGuard().
void CRWLock::ReadLock | ( | void | ) |
Read lock.
Acquire the R-lock. If W-lock is already acquired by another thread, then wait until it is released.
Definition at line 863 of file ncbimtx.cpp.
References _VERIFY, CRWLock::fTrackReaders, GetCurrentThreadSystemID(), HANDLE, interlocked_dec_max(), interlocked_inc_min(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, CRWLock::m_WaitingWriters, TRUE, CRWLock::x_MayAcquireForReading(), xncbi_Validate, xncbi_ValidateAndErrnoReport, and xncbi_ValidatePthread.
Referenced by IRegistry::ReadLock(), s_LOCK_Handler(), and CRWLock::TryReadLock().
void CFastRWLock::ReadLock | ( | void | ) |
Acquire read lock.
Definition at line 2048 of file ncbimtx.cpp.
References CAtomicCounter::Add(), CFastRWLock::kWriteLockValue, CFastMutex::Lock(), CFastRWLock::m_LockCount, CFastRWLock::m_WriteLock, and CFastMutex::Unlock().
void CFastRWLock::ReadUnlock | ( | void | ) |
Release read lock.
Definition at line 2062 of file ncbimtx.cpp.
References CAtomicCounter::Add(), and CFastRWLock::m_LockCount.
void CUsedTlsBases::Register | ( | CTlsBase * | tls | ) |
Definition at line 111 of file ncbithr.cpp.
References CObject::AddReference(), set< Key, Compare >::insert(), CTlsBase::m_AutoDestroy, and CUsedTlsBases::m_UsedTls.
Referenced by CTlsBase::x_SetValue().
|
inline |
Forger lock.
Definition at line 132 of file lock_vector.hpp.
void CRWLockHolder::ReleaseLock | ( | void | ) |
Release the lock held or cancel request for the lock.
Referenced by CRWLockHolder::~CRWLockHolder().
void CRWLockHolder::RemoveListener | ( | IRWLockHolder_Listener * | listener | ) |
Remove object keeping track of holder state changes.
void CRWLockHolder::Reset | ( | void | ) |
Reset holder to be able to use it later (after calling Init() )
Referenced by CRWLockHolder_Pool::DeleteHolder().
|
inline |
Reset thread local storage.
Reset thread local storage to its initial value (as it was before the first call to SetValue()). Do cleanup if the cleanup function was specified in the previous call to SetValue().
Reset() will always be called automatically on the thread termination, or when the TLS is destroyed.
Definition at line 217 of file ncbithr.hpp.
Referenced by CCgiApplication::Exit(), and CCgiProcessorGuard::~CCgiProcessorGuard().
bool CThread::Run | ( | TRunMode | flags = fRunDefault | ) |
Run the thread.
Create a new thread, initialize it, and call user-provided Main() method.
Definition at line 724 of file ncbithr.cpp.
References CRequestContext::Clone(), FALSE, flags, CThread::fRunAllowST, CThread::fRunCloneRequestContext, CThread::fRunDetached, CThread::fRunNice, CThread::fRunUnbound, CDiagContext::GetRequestContext(), HANDLE, CUsedTlsBases::Init(), CThread::m_Handle, CThread::m_IsDetached, CThread::m_IsRun, CThread::m_ParentRequestContext, CThread::m_SelfRef, NCBI_THREAD_VALIDATE, NULL, CRef< C, Locker >::Reset(), CThread::sm_ThreadsCount, ThreadWrapperCallerImpl(), and CThread::Wrapper().
Referenced by BOOST_AUTO_TEST_CASE(), CNSTDatabase::CNSTDatabase(), CScheduler_ExecThread_Impl::CScheduler_ExecThread_Impl(), CSchedulerEngine::CSchedulerEngine(), CWGSDataLoader_Impl::GetResolver(), CWGSClient::GetWGSResolver(), CAsyncDiagHandler::InstallToDiag(), CDataSource::Prefetch(), CMergeyApp::Run(), CMagicBlastApp::Run(), SGridWorkerNodeImpl::Run(), CBlastKmerApplication::Run(), CBDB_Env::RunBackgroundWriter(), CQueueDataBase::RunExecutionWatcherThread(), CNCMMCentral::RunLateInit(), CQueueDataBase::RunNotifThread(), CQueueDataBase::RunPurgeThread(), CQueueDataBase::RunServiceThread(), CNetStorageServer::RunServiceThread(), CThreadPool_Impl::SetInterfaceStarted(), CAsyncTaskProcessor< CRemoteAppReaperTask >::CExecutor::Start(), SNetScheduleAPIImpl::StartNotificationThread(), CBDB_Cache::StartPurgeThread(), CMMAligner::x_DoSubmatrix(), and CNWAligner::x_Run().
|
inline |
volatile versions of above methods
Definition at line 205 of file ncbimtx.hpp.
References CThreadSystemID::m_ID.
|
static |
Set name for the current thread.
This works only on Linux, no-op on other platforms
Definition at line 958 of file ncbithr.cpp.
Referenced by CMainLoopThread::Main(), SNetScheduleNotificationThread::Main(), CJobCommitterThread::Main(), CThreadInPool_ForServer::Main(), CThreadInPool< TRequest >::Main(), CAsyncTaskProcessor< TTask >::CExecutor::SThread::Main(), CGetJobNotificationThread::Main(), CServiceThread::Main(), CJobQueueCleanerThread::Main(), CJobQueueExecutionWatcherThread::Main(), CNSTDBConnectionThread::Main(), CNetStorageServiceThread::Main(), CGridControlThread::Main(), CWorkerNodeIdleThread::Main(), and CAsyncDiagThread::Main().
|
inline |
Assign Id (no locking)
Definition at line 138 of file lock_vector.hpp.
Referenced by CBDB_Cache::BlobCheckIn().
|
inline |
Definition at line 338 of file ncbithr.hpp.
Referenced by GetCTLExceptionStorage(), CDiagContextThreadData::GetThreadData(), CUsedTlsBases::GetUsedTlsBases(), and Ncbi_strerror().
|
inline |
Set value.
Cleanup previously stored value, and set the new value. The "cleanup" function and "cleanup_data" will be used to destroy the new "value" in the next call to SetValue() or Reset(). Do not cleanup if the new value is equal to the old one.
value | New value to set. |
cleanup | Cleanup function. Do not cleanup if default of 0 is specified or if new value is the same as old value. |
cleanup_data | One of the parameters to the cleanup function. |
Definition at line 203 of file ncbithr.hpp.
Referenced by CCgiApplication::x_CreateProcessor(), and CLDS2_UrlHandler_File::x_GetStreamCache().
Set timeout for stopping all threads on application exit.
Definition at line 968 of file ncbithr.cpp.
References CThread::sm_WaitForThreadsTimeout.
void CConditionVariable::SignalAll | ( | void | ) |
Wake all threads that are currently waiting on the condition variable.
Definition at line 2616 of file ncbimtx.cpp.
References CConditionVariable::m_ConditionVar, and NCBI_THROW.
Referenced by CNCMMCentral::PrepareToStop(), CBlockingQueue_ForServer::Put(), and CTSE_LoadLockGuard::Release().
void CConditionVariable::SignalSome | ( | void | ) |
Wake at least one of the threads that are currently waiting on this condition variable (if any threads are waiting on it).
Definition at line 2594 of file ncbimtx.cpp.
References CConditionVariable::m_ConditionVar, and NCBI_THROW.
Referenced by CAsyncTaskProcessor< CRemoteAppReaperTask >::CContext::ExecutorImplStop(), CAsyncTaskProcessor< TTask >::CContext::SchedulerImpl(), and CBlastNodeMailbox::SendMsg().
void CLockVectorGuard< BV >::TakeFrom | ( | CLockVectorGuard< TLockVect > & | lg | ) |
Transfer lock ownership from another lock.
lg | Old lock guard (lock src) |
Definition at line 271 of file lock_vector.hpp.
References lg().
Referenced by CBDB_CacheIReader::CBDB_CacheIReader(), and CBDB_CacheIWriter::CBDB_CacheIWriter().
|
static |
Throw lock failed("eLocked") exception.
Definition at line 233 of file ncbimtx.cpp.
References NCBI_THROW.
|
static |
Throw not owned("eOwner") exception.
Definition at line 418 of file ncbimtx.cpp.
References NCBI_THROW.
|
static |
Throw try lock failed("eTryLock") exception.
Definition at line 243 of file ncbimtx.cpp.
References NCBI_THROW.
|
static |
Throw uninitialized ("eUninitialized") exception.
Definition at line 228 of file ncbimtx.cpp.
References eUninitialized, and NCBI_THROW.
|
static |
Throw unlock failed("eUnlocked") exception.
Definition at line 238 of file ncbimtx.cpp.
References NCBI_THROW.
|
inlinestatic |
Definition at line 256 of file ncbithr.hpp.
|
inlinestatic |
Definition at line 248 of file ncbithr.hpp.
bool CLockVector< BV >::TryLock | ( | unsigned | id | ) |
Try to acquire lock of specified id.
Definition at line 296 of file lock_vector.hpp.
Referenced by CBDB_Cache::GetNextBlobId().
bool SSystemFastMutex::TryLock | ( | void | ) |
Try to lock.
Definition at line 284 of file ncbimtx.cpp.
References WRITE_MUTEX_EVENT.
bool SSystemMutex::TryLock | ( | void | ) |
Try to lock.
Definition at line 371 of file ncbimtx.cpp.
References assert, count, and GetCurrentThreadSystemID().
bool CFastMutex::TryLock | ( | void | ) |
Try locking the mutex.
bool CMutex::TryLock | ( | void | ) |
Try locking mutex.
Try to acquire the mutex.
Referenced by CAppJobDispatcher::OnEngineJobStateChanged().
bool CSpinLock::TryLock | ( | void | ) |
Attempt to lock the mutex and return TRUE if it succeeded or FALSE if mutex is locked by other thread.
Definition at line 2336 of file ncbimtx.cpp.
References CSpinLock::m_Value, NULL, and SwapPointers().
Try read lock with timeout.
timeout | Timeout for the read lock attempt. |
Definition at line 1050 of file ncbimtx.cpp.
References _VERIFY, CRWLock::fTrackReaders, CTimeout::GetAsMilliSeconds(), GetCurrentThreadSystemID(), CDeadline::GetExpirationTime(), CTimeout::GetNano(), HANDLE, interlocked_dec_max(), interlocked_inc_min(), CTimeout::IsInfinite(), CTimeout::IsZero(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, CRWLock::m_WaitingWriters, ok, CRWLock::ReadLock(), TRUE, CRWLock::TryReadLock(), CRWLock::x_MayAcquireForReading(), xncbi_Validate, and xncbi_ValidateAndErrnoReport.
bool CRWLock::TryReadLock | ( | void | ) |
Try read lock.
Try to acquire R-lock and return immediately.
Definition at line 976 of file ncbimtx.cpp.
References _VERIFY, CRWLock::fTrackReaders, GetCurrentThreadSystemID(), interlocked_dec_max(), interlocked_inc_min(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, CRWLock::x_MayAcquireForReading(), and xncbi_Validate.
Referenced by s_LOCK_Handler(), and CRWLock::TryReadLock().
Timed wait. Wait time specified by CTimeout.
Definition at line 1958 of file ncbimtx.cpp.
References CTimeout::GetNano(), CTimeout::IsInfinite(), CSemaphore::TryWait(), and CSemaphore::Wait().
Timed wait.
Wait up to timeout_sec + timeout_nsec/1E9 seconds for the semaphore's count to exceed zero. If that happens, decrement the counter by one and return TRUE; otherwise, return FALSE.
Definition at line 1844 of file ncbimtx.cpp.
References SSemaphore::cond, SSemaphore::count, kMax_Int, CSemaphore::m_Sem, SSemaphore::mutex, SSemaphore::wait_count, xncbi_Validate, and xncbi_ValidatePthread.
Referenced by SGridWorkerNodeImpl::EnterExclusiveMode(), CBDB_Cache::EvaluateTimeLine(), SServerNotifications::GetNextNotification(), SServerNotifications::InterruptWait(), CThreadNonStop::Main(), CGetJobNotificationThread::Main(), CJobQueueCleanerThread::Main(), CJobQueueExecutionWatcherThread::Main(), CWorkerNodeIdleThread::Main(), CScheduler_ExecThread_Impl::Main(), impl::CDriverContext::MakePooledConnection(), CBDB_Cache::Purge(), CSemaphore::TryWait(), CGridCleanupThread::Wait(), SGridWorkerNodeImpl::WaitForExclusiveJobToFinish(), CJobCommitterThread::WaitForTimeout(), CNSTDBConnectionThread::x_CreateDatabase(), CThreadPool_ServiceThread::x_Idle(), CSyncQueue< Type, Container, Traits >::x_LockAndWait(), impl::CDriverContext::x_Recycle(), CNSTDBConnectionThread::x_RestoreConnection(), CBlockingQueue< TRequest >::x_WaitForPredicate(), CThreadPool_Impl::x_WaitForPredicate(), and CSchedulerEngine::x_WorkOnThread().
Try write lock with timeout.
timeout | Timeout for the write lock attempt. |
Definition at line 1386 of file ncbimtx.cpp.
References _ASSERT, _VERIFY, CRWLock::fFavorWriters, CTimeout::GetAsMilliSeconds(), GetCurrentThreadSystemID(), CDeadline::GetExpirationTime(), CTimeout::GetNano(), HANDLE, interlocked_dec_max(), interlocked_set(), CTimeout::IsInfinite(), CTimeout::IsZero(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, CRWLock::m_WaitingWriters, ok, TRUE, CRWLock::TryWriteLock(), CRWLock::WriteLock(), xncbi_Validate, and xncbi_ValidateAndErrnoReport.
bool CRWLock::TryWriteLock | ( | void | ) |
Try write lock.
Try to acquire W-lock and return immediately.
Definition at line 1320 of file ncbimtx.cpp.
References _ASSERT, _VERIFY, GetCurrentThreadSystemID(), HANDLE, interlocked_dec_max(), interlocked_set(), CRWLock::m_Count, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, TRUE, and xncbi_Validate.
Referenced by s_LOCK_Handler(), and CRWLock::TryWriteLock().
void CLockVectorGuard< TLockVect >::Unlock | ( | void | ) |
Unlocks the lock.
Definition at line 255 of file lock_vector.hpp.
References _ASSERT, msg(), NCBI_THROW, and NStr::UIntToString().
Referenced by CBDB_CacheIWriter::Flush().
void SSystemFastMutex::Unlock | ( | ELockSemantics | lock = eNormal | ) |
Release mutex with no owner or nesting checks.
Definition at line 324 of file ncbimtx.cpp.
References WRITE_MUTEX_EVENT.
void SSystemMutex::Unlock | ( | SSystemFastMutex::ELockSemantics | lock = SSystemFastMutex::eNormal | ) |
Release mutex.
Definition at line 395 of file ncbimtx.cpp.
References count, and GetCurrentThreadSystemID().
bool CLockVector< BV >::Unlock | ( | unsigned | id | ) |
Unlock object.
Definition at line 304 of file lock_vector.hpp.
References _ASSERT.
void CFastMutex::Unlock | ( | void | ) |
Release mutex with no owner or nesting checks.
Referenced by CRtProfiler::AddMarkerMT(), CRtProfiler::AddUserKVMT(), CRtProfiler::AsStringMT(), BlastLockHandler(), CBlastAsyncFormatThread::Finalize(), CServer_ConnectionPool::GetListenerPorts(), CServer_ConnectionPool::GetPollAndTimerVec(), CBlastAsyncFormatThread::Main(), CBlastKmerThread::Main(), CBlastAsyncFormatThread::QueueResults(), CFastRWLock::ReadLock(), CServer_ConnectionPool::RemoveListener(), CServer_ConnectionPool::SetAllActive(), CRtProfiler::StartMT(), CRtProfiler::StopMT(), CThreadGroup::SyncPoint(), CBDB_Cache::Unlock(), CDBConnectionFactory::CServiceInfo::Unlock(), CConditionVariable::WaitForSignal(), CFastRWLock::WriteUnlock(), CNCMMCentral::x_DoBackgroundWork(), and CNSTDBConnectionThread::x_RestoreConnection().
void CMutex::Unlock | ( | void | ) |
Unlock mutex.
Operation:
Referenced by CAppJobDispatcher::OnEngineJobStateChanged(), CGBProject::Unlock(), CAppJobDispatcher::Unlock(), CSafeStaticPtr_Base::Unlock(), and CInfoManager::x_UnlockInfoMutex().
void CSpinLock::Unlock | ( | void | ) |
Unlock the mutex.
There's no check that mutex is unlocked by the same thread that locked it.
Definition at line 2342 of file ncbimtx.cpp.
References _VERIFY, CSpinLock::m_Value, NULL, and SwapPointers().
Referenced by CObjPool< CRWLockHolder, THolderPoolFactory >::Clear(), CObjPool< CRWLockHolder, THolderPoolFactory >::Get(), CObjPool< CRWLockHolder, THolderPoolFactory >::Return(), CRWLockHolder::x_OnLockAcquired(), and CRWLockHolder::x_OnLockReleased().
void CRWLock::Unlock | ( | void | ) |
Release the RW-lock.
Definition at line 1558 of file ncbimtx.cpp.
References _ASSERT, _VERIFY, cnt, CRWLock::fTrackReaders, GetCurrentThreadSystemID(), interlocked_dec_min(), interlocked_inc_max(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, CRWLock::m_WaitingWriters, xncbi_Validate, and xncbi_ValidatePthread.
Referenced by s_LOCK_Handler(), and IRegistry::Unlock().
void CSemaphore::Wait | ( | void | ) |
Wait on semaphore.
Decrement the counter by one. If the semaphore's count is zero then wait until it's not zero.
Definition at line 1787 of file ncbimtx.cpp.
References SSemaphore::cond, SSemaphore::count, CSemaphore::m_Sem, SSemaphore::mutex, SSemaphore::wait_count, xncbi_Validate, and xncbi_ValidatePthread.
Referenced by CPSGL_QueueGuard::GetNextResult(), CTestThread::GlobalSyncPoint(), CJobCommitterThread::Main(), CBlastAsyncFormatThread::Main(), CPrefetchThreadOld::Main(), CNSTDBConnectionThread::Main(), CAsyncDiagThread::Main(), CThreadPool_ServiceThread::Main(), CIStreamObjectIteratorThread< TRoot, TObject >::Main(), CIStreamStdIteratorThread< TRoot, TObject >::Main(), CIStreamIteratorThread_Base< TRoot, TObject >::Next(), CIStreamIteratorThread_Base< TRoot, TObject >::SetObject(), CThreadGroup::SyncPoint(), CThreadGroup::ThreadWait(), CSemaphore::TryWait(), CPSGL_RequestTracker::WaitForBackgroundTasks(), CReader::x_AllocConnection(), CThreadPool_ThreadImpl::x_Idle(), CSyncQueue< Type, Container, Traits >::x_LockAndWait(), and CThreadPool_Impl::x_WaitForPredicate().
|
staticprivate |
Definition at line 974 of file ncbithr.cpp.
References CStopWatch::Elapsed(), CStopWatch::eStart, CTimeout::GetAsMilliSeconds(), CTimeout::IsInfinite(), CThread::IsMain(), SleepMilliSec(), CThread::sm_ThreadsCount, CThread::sm_WaitForThreadsTimeout, and sw.
Referenced by CNcbiApplicationAPI::~CNcbiApplicationAPI().
bool CConditionVariable::WaitForSignal | ( | CFastMutex & | mutex, |
const CDeadline & | deadline = CDeadline::eInfinite |
||
) |
Release mutex and lock the calling thread until the condition variable is signalled.
mutex | Mutex to release while waiting for a signal. At the time of the call the mutex must be locked by this thread. Otherwise, an exception will be thrown. |
deadline | The wait will time out when system time equals or exceeds the absolute time specified in 'deadline' |
Definition at line 2579 of file ncbimtx.cpp.
References CFastMutex::Unlock(), and CConditionVariable::x_WaitForSignal().
bool CConditionVariable::WaitForSignal | ( | CMutex & | mutex, |
const CDeadline & | deadline = CDeadline::eInfinite |
||
) |
Release mutex and lock the calling thread until the condition variable is signalled.
mutex | Mutex to release while waiting for a signal. At the time of the call the mutex must be locked by this thread exactly once. Otherwise, an exception will be thrown. |
deadline | The wait will time out when system time equals or exceeds the absolute time specified in 'deadline' |
Definition at line 2554 of file ncbimtx.cpp.
References GetCurrentThreadSystemID(), NCBI_THROW, and CConditionVariable::x_WaitForSignal().
Referenced by CBlockingQueue_ForServer::GetHandle(), WaitCondVar(), CTSE_LoadLockGuard::WaitForSignal(), CNCMMCentral::x_DoBackgroundWork(), and CBlastMasterNode::x_WaitForNewEvent().
|
staticprivate |
Function to use (internally) as the thread's startup function.
Definition at line 552 of file ncbithr.cpp.
References CUsedTlsBases::ClearAllCurrentThread(), CExitThreadException::EnterWrapper(), CThread::IsMain(), CThread::m_ExitData, CThread::m_IsDetached, CThread::m_IsTerminated, CThread::m_ParentRequestContext, CThread::m_SelfRef, CThread::Main(), NCBI_CATCH_ALL_X, NCBI_CATCH_X, CThread::OnExit(), CRef< C, Locker >::Reset(), CDiagContext::SetRequestContext(), CThread::sm_ThreadsCount, CThread::x_InitializeThreadId(), and xncbi_Validate.
Referenced by CThread::Run(), and ThreadWrapperCaller().
void CRWLock::WriteLock | ( | void | ) |
Write lock.
Acquire the W-lock. If R-lock or W-lock is already acquired by another thread, then wait until it is released.
Definition at line 1201 of file ncbimtx.cpp.
References _ASSERT, _VERIFY, CRWLock::fFavorWriters, GetCurrentThreadSystemID(), HANDLE, interlocked_dec_max(), interlocked_set(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Owner, CRWLock::m_Readers, CRWLock::m_RW, CRWLock::m_WaitingWriters, TRUE, xncbi_Validate, xncbi_ValidateAndErrnoReport, and xncbi_ValidatePthread.
Referenced by s_LOCK_Handler(), CRWLock::TryWriteLock(), and IRegistry::WriteLock().
void CFastRWLock::WriteLock | ( | void | ) |
Acquire write lock.
Definition at line 2072 of file ncbimtx.cpp.
References CAtomicCounter::Add(), CAtomicCounter::Get(), CFastRWLock::kWriteLockValue, CFastMutex::Lock(), CFastRWLock::m_LockCount, CFastRWLock::m_WriteLock, and NCBI_SCHED_YIELD.
void CFastRWLock::WriteUnlock | ( | void | ) |
Release write lock.
Definition at line 2086 of file ncbimtx.cpp.
References CAtomicCounter::Add(), CFastRWLock::kWriteLockValue, CFastRWLock::m_LockCount, CFastRWLock::m_WriteLock, and CFastMutex::Unlock().
|
staticprivate |
Definition at line 210 of file ncbithr.cpp.
References CTlsBase::CleanupAndDeleteTlsData().
Referenced by CTlsBase::x_Init().
|
private |
Deletes STlsData* structure and managed pointer Returns true if CTlsBase must be deregistered from current thread.
Definition at line 322 of file ncbithr.cpp.
References CTlsBase::CleanupAndDeleteTlsData(), CTlsBase::m_Initialized, CTlsBase::m_Key, s_TlsSetValue(), and CTlsBase::x_GetTlsData().
Referenced by CUsedTlsBases::ClearAll(), and CTlsBase::x_Reset().
|
protected |
Destroy thread data.
Definition at line 234 of file ncbithr.cpp.
References assert, CTlsBase::m_Initialized, CTlsBase::m_Key, and CTlsBase::x_Reset().
Referenced by CTlsBase::~CTlsBase().
|
inlineprivate |
Definition at line 260 of file ncbithr.hpp.
References CSimpleStaticTls< V >::m_Key, and CSimpleStaticTls< V >::x_GetKeyLong().
Referenced by CSimpleStaticTls< V >::operator value_type(), and CSimpleStaticTls< V >::operator=().
|
inlineprivate |
Definition at line 263 of file ncbithr.hpp.
References _ASSERT, _VERIFY, DEFINE_STATIC_FAST_MUTEX, and CSimpleStaticTls< V >::m_Key.
Referenced by CSimpleStaticTls< V >::x_GetKey().
|
inlineprivate |
Helper method to get the STlsData*.
Definition at line 725 of file ncbithr.hpp.
References CTlsBase::m_Initialized, and CTlsBase::m_Key.
Referenced by CTlsBase::x_DeleteTlsData(), CTlsBase::x_GetValue(), and CTlsBase::x_SetValue().
|
inlineprotected |
Helper method to get stored thread data.
Definition at line 747 of file ncbithr.hpp.
References CTlsBase::STlsData::m_Value, and CTlsBase::x_GetTlsData().
Referenced by CTls< CCgiRequestProcessor >::GetValue().
|
protected |
Initialize thread data.
Definition at line 216 of file ncbithr.cpp.
References CTlsBase::m_Initialized, CTlsBase::m_Key, CTlsBase::x_CleanupThreadCallback(), and xncbi_VerifyAndErrorReport.
Referenced by CTls< CCgiRequestProcessor >::CTls().
|
private |
initalize new thread id, must be called from Wrapper().
Definition at line 471 of file ncbithr.cpp.
References _ASSERT, and sx_GetNextThreadId().
Referenced by CThread::Wrapper().
|
inlineprivate |
Definition at line 725 of file ncbimtx.cpp.
References _ASSERT, CRWLock::fFavorWriters, GetCurrentThreadSystemID(), CRWLock::m_Count, CRWLock::m_Flags, CRWLock::m_Readers, and CRWLock::m_WaitingWriters.
Referenced by CRWLock::ReadLock(), and CRWLock::TryReadLock().
|
private |
Callback called at the moment when lock is granted.
Definition at line 2118 of file ncbimtx.cpp.
References CSpinLock::Lock(), CRWLockHolder::m_Listeners, CRWLockHolder::m_ObjLock, NON_CONST_ITERATE, CRef< C, Locker >::NotNull(), and CSpinLock::Unlock().
|
private |
Callback called at the moment when lock is released.
Method is not called if request for lock was canceled before it was actually granted.
Definition at line 2135 of file ncbimtx.cpp.
References CSpinLock::Lock(), CRWLockHolder::m_Listeners, CRWLockHolder::m_ObjLock, NON_CONST_ITERATE, CRef< C, Locker >::NotNull(), and CSpinLock::Unlock().
Referenced by CYieldingRWLock::x_ReleaseLock().
|
private |
Main implementation releasing lock.
Definition at line 2265 of file ncbimtx.cpp.
References eReadLock, eWriteLock, CRWLockHolder::m_LockAcquired, CYieldingRWLock::m_Locks, CYieldingRWLock::m_LockWaits, CYieldingRWLock::m_ObjLock, CRWLockHolder::m_Type, NON_CONST_ITERATE, CRef< C, Locker >::NotNull(), and CRWLockHolder::x_OnLockReleased().
|
protected |
Helper method to reset thread data.
Definition at line 345 of file ncbithr.cpp.
References CUsedTlsBases::Deregister(), CUsedTlsBases::GetUsedTlsBases(), and CTlsBase::x_DeleteTlsData().
Referenced by CTls< CCgiRequestProcessor >::Discard(), CTls< CCgiRequestProcessor >::Reset(), and CTlsBase::x_Destroy().
|
protected |
Helper method to set thread data.
Definition at line 274 of file ncbithr.cpp.
References cleanup(), CTlsBase::CleanupTlsData(), CTlsBase::eSkipCleanup, CUsedTlsBases::GetUsedTlsBases(), CTlsBase::STlsData::m_CleanupData, CTlsBase::STlsData::m_CleanupFunc, CTlsBase::m_Initialized, CTlsBase::m_Key, CTlsBase::STlsData::m_Native, CTlsBase::STlsData::m_Value, CUsedTlsBases::Register(), s_TlsSetValue(), rapidjson::value, CTlsBase::x_GetTlsData(), and xncbi_Validate.
Referenced by CTls< CCgiRequestProcessor >::SetValue().
|
private |
Definition at line 2491 of file ncbimtx.cpp.
References CTimeout::GetAsMilliSeconds(), CDeadline::GetExpirationTime(), CDeadline::GetRemainingTime(), CDeadline::IsInfinite(), CConditionVariable::m_ConditionVar, CConditionVariable::m_WaitCounter, CConditionVariable::m_WaitMutex, NCBI_THROW, and s_ThrowIfDifferentMutexes().
Referenced by CConditionVariable::WaitForSignal().
CConditionVariable::~CConditionVariable | ( | void | ) |
Definition at line 2400 of file ncbimtx.cpp.
References Critical(), ERR_POST, CConditionVariable::m_ConditionVar, and NCBI_TROUBLE.
CFastMutex::~CFastMutex | ( | void | ) |
Destructor.
Close mutex handle. No checks if it's still acquired.
CFastRWLock::~CFastRWLock | ( | void | ) |
CLockVector< BV >::~CLockVector |
Definition at line 287 of file lock_vector.hpp.
References ERR_POST_XX.
CLockVectorGuard< TLockVect >::~CLockVectorGuard |
Definition at line 196 of file lock_vector.hpp.
References ERR_POST_XX.
CMutex::~CMutex | ( | void | ) |
Destructor.
Report error if the mutex is locked.
CRWLock::~CRWLock | ( | void | ) |
|
virtual |
Definition at line 2104 of file ncbimtx.cpp.
References CRWLockHolder::m_Lock, and CRWLockHolder::ReleaseLock().
CSemaphore::~CSemaphore | ( | void | ) |
Destructor.
Report error if the semaphore is locked.
Definition at line 1758 of file ncbimtx.cpp.
References _ASSERT, SSemaphore::cond, CSemaphore::m_Sem, SSemaphore::mutex, SSemaphore::wait_count, and xncbi_VerifyAndErrorReport.
CSpinLock::~CSpinLock | ( | void | ) |
|
protectedvirtual |
To be called only internally! NOTE: destructor of the derived (user-provided) class should be declared "protected", too!
Definition at line 659 of file ncbithr.cpp.
References CThread::m_Handle, CThread::m_IsRun, and NULL.
|
inlineprotected |
Destructor.
Cleanup data and delete TLS key.
Definition at line 98 of file ncbithr.hpp.
References CTlsBase::m_AutoDestroy, and CTlsBase::x_Destroy().
CUsedTlsBases::~CUsedTlsBases | ( | void | ) |
Definition at line 77 of file ncbithr.cpp.
CYieldingRWLock::~CYieldingRWLock | ( | void | ) |
It is fatal error to destroy the object while some locks are pending.
Thus this object should be destroyed only after calls to ReleaseLock() for all CRWLockHolder objects.
Definition at line 2217 of file ncbimtx.cpp.
References eReadLock, ERR_POST_X, eWriteLock, CYieldingRWLock::m_Locks, CYieldingRWLock::m_LockWaits, CYieldingRWLock::m_ObjLock, and RWLockFatal.
|
virtual |
Definition at line 2100 of file ncbimtx.cpp.
|
virtual |
Definition at line 2097 of file ncbimtx.cpp.
const CThread::TID kThreadID_None = 0xFFFFFFFF |
Definition at line 791 of file ncbithr.hpp.
|
private |
Indicates if object should be destroyed in destructor.
Definition at line 124 of file ncbithr.hpp.
Referenced by CUsedTlsBases::ClearAll(), CUsedTlsBases::Deregister(), CUsedTlsBases::Register(), and CTlsBase::~CTlsBase().
|
private |
Definition at line 313 of file ncbithr.hpp.
Referenced by CStaticTls_Callbacks< CUsedTlsBases >::Cleanup().
void* CTlsBase::STlsData::m_CleanupData |
Definition at line 131 of file ncbithr.hpp.
Referenced by CTlsBase::CleanupTlsData(), and CTlsBase::x_SetValue().
FCleanupBase CTlsBase::STlsData::m_CleanupFunc |
Definition at line 130 of file ncbithr.hpp.
Referenced by CTlsBase::CleanupTlsData(), and CTlsBase::x_SetValue().
|
private |
Definition at line 1501 of file ncbimtx.hpp.
Referenced by CConditionVariable::SignalAll(), CConditionVariable::SignalSome(), CConditionVariable::x_WaitForSignal(), and CConditionVariable::~CConditionVariable().
atomic<int> ncbi_namespace_mutex_mt::SSystemMutex::m_Count |
# of recursive (in the same thread) locks
Definition at line 415 of file ncbimtx.hpp.
|
private |
Number of readers (if >0) or writers (if <0)
Definition at line 1046 of file ncbimtx.hpp.
Referenced by CRWLock::ReadLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), CRWLock::Unlock(), CRWLock::WriteLock(), CRWLock::x_MayAcquireForReading(), and CRWLock::~CRWLock().
|
private |
as returned by Main() or passed to Exit()
Definition at line 657 of file ncbithr.hpp.
Referenced by CThread::Exit(), CThread::Join(), and CThread::Wrapper().
|
private |
Factory created the holder.
Definition at line 1286 of file ncbimtx.hpp.
Referenced by CRWLockHolder::DeleteThis().
|
private |
Factory creating CRWLockHolder objects.
Definition at line 1357 of file ncbimtx.hpp.
Referenced by CYieldingRWLock::AcquireLock(), and CYieldingRWLock::CYieldingRWLock().
|
private |
Configuration flags.
Definition at line 1043 of file ncbimtx.hpp.
Referenced by CRWLock::CRWLock(), CRWLock::ReadLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), CRWLock::Unlock(), CRWLock::WriteLock(), and CRWLock::x_MayAcquireForReading().
TSystemMutex ncbi_namespace_mutex_mt::SSystemFastMutex::m_Handle |
Mutex handle.
Definition at line 277 of file ncbimtx.hpp.
|
private |
platform-dependent thread handle
Definition at line 651 of file ncbithr.hpp.
Referenced by CThread::Detach(), CThread::GetThreadHandle(), CThread::Join(), CThread::Run(), and CThread::~CThread().
TID CThreadSystemID::m_ID |
Thread ID.
Definition at line 182 of file ncbimtx.hpp.
Referenced by CThreadSystemID::GetCurrent(), CThreadSystemID::Is(), CThreadSystemID::IsNot(), CThreadSystemID::operator!=(), CThreadSystemID::operator==(), and CThreadSystemID::Set().
|
private |
Definition at line 163 of file lock_vector.hpp.
Referenced by CLockVectorGuard< TLockVector >::GetId(), and CLockVectorGuard< TLockVector >::SetId().
|
protected |
vector of locked objs
Definition at line 89 of file lock_vector.hpp.
|
mutableprotected |
lock for m_LockVector
Definition at line 90 of file lock_vector.hpp.
|
private |
Indicates if thread data initialized.
Definition at line 123 of file ncbithr.hpp.
Referenced by CTlsBase::x_DeleteTlsData(), CTlsBase::x_Destroy(), CTlsBase::x_GetTlsData(), CTlsBase::x_Init(), and CTlsBase::x_SetValue().
|
private |
if the thread is detached
Definition at line 653 of file ncbithr.hpp.
Referenced by CThread::Detach(), CThread::Join(), CThread::Run(), and CThread::Wrapper().
|
private |
if Join() was called for the thread
Definition at line 654 of file ncbithr.hpp.
Referenced by CThread::Join().
|
private |
if Run() was called for the thread
Definition at line 652 of file ncbithr.hpp.
Referenced by CThread::Detach(), CThread::Discard(), CThread::Join(), CThread::Run(), and CThread::~CThread().
|
private |
if Exit() was called for the thread
Definition at line 655 of file ncbithr.hpp.
Referenced by CThread::Detach(), CThread::IsTerminated(), and CThread::Wrapper().
|
private |
Definition at line 122 of file ncbithr.hpp.
Referenced by CTlsBase::x_DeleteTlsData(), CTlsBase::x_Destroy(), CTlsBase::x_GetTlsData(), CTlsBase::x_Init(), and CTlsBase::x_SetValue().
|
mutableprivate |
Definition at line 243 of file ncbithr.hpp.
Referenced by CSimpleStaticTls< V >::x_GetKey(), and CSimpleStaticTls< V >::x_GetKeyLong().
|
private |
List of holder listeners.
Definition at line 1296 of file ncbimtx.hpp.
Referenced by CRWLockHolder::x_OnLockAcquired(), and CRWLockHolder::x_OnLockReleased().
|
private |
Lock object the holder is assigned to.
Definition at line 1288 of file ncbimtx.hpp.
Referenced by CRWLockHolder::~CRWLockHolder().
|
private |
Flag if lock was acquired.
Definition at line 1292 of file ncbimtx.hpp.
Referenced by CYieldingRWLock::x_ReleaseLock().
|
private |
Number of read locks acquired or value of kWriteLockValue if write lock was acquired.
Definition at line 1167 of file ncbimtx.hpp.
Referenced by CFastRWLock::ReadLock(), CFastRWLock::ReadUnlock(), CFastRWLock::WriteLock(), and CFastRWLock::WriteUnlock().
|
private |
Number of locks granted on this object by type.
Definition at line 1361 of file ncbimtx.hpp.
Referenced by CYieldingRWLock::AcquireLock(), CYieldingRWLock::CYieldingRWLock(), CYieldingRWLock::x_ReleaseLock(), and CYieldingRWLock::~CYieldingRWLock().
|
private |
Definition at line 166 of file lock_vector.hpp.
Referenced by CLockVectorGuard< TLockVector >::Release().
|
private |
Definition at line 162 of file lock_vector.hpp.
Referenced by CLockVectorGuard< TLockVector >::GetLockVector().
|
private |
Queue for waiting lock requests.
Definition at line 1363 of file ncbimtx.hpp.
Referenced by CYieldingRWLock::AcquireLock(), CYieldingRWLock::x_ReleaseLock(), and CYieldingRWLock::~CYieldingRWLock().
volatile EMagic ncbi_namespace_mutex_mt::SSystemFastMutex::m_Magic |
Magic flag.
Definition at line 284 of file ncbimtx.hpp.
SSystemFastMutex ncbi_namespace_mutex_mt::SSystemMutex::m_Mutex |
Mutex value.
Definition at line 411 of file ncbimtx.hpp.
|
private |
Platform-dependent mutex handle, also used by CRWLock.
Definition at line 713 of file ncbimtx.hpp.
Referenced by CFastMutex::GetHandle().
|
private |
System mutex.
Definition at line 799 of file ncbimtx.hpp.
ENativeThreadCleanup CTlsBase::STlsData::m_Native |
Definition at line 132 of file ncbithr.hpp.
Referenced by CTlsBase::CleanupTlsData(), and CTlsBase::x_SetValue().
|
private |
Mutex for operating listeners.
Definition at line 1294 of file ncbimtx.hpp.
Referenced by CRWLockHolder::x_OnLockAcquired(), and CRWLockHolder::x_OnLockReleased().
|
private |
Main locking mutex for object operations.
Definition at line 1359 of file ncbimtx.hpp.
Referenced by CYieldingRWLock::AcquireLock(), CYieldingRWLock::x_ReleaseLock(), and CYieldingRWLock::~CYieldingRWLock().
atomic<TThreadSystemID> ncbi_namespace_mutex_mt::SSystemMutex::m_Owner |
Platform-dependent owner thread ID.
Definition at line 413 of file ncbimtx.hpp.
|
private |
Writer ID, one of the readers ID.
Definition at line 1045 of file ncbimtx.hpp.
Referenced by CRWLock::ReadLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), CRWLock::Unlock(), and CRWLock::WriteLock().
|
private |
Definition at line 658 of file ncbithr.hpp.
Referenced by CThread::Run(), and CThread::Wrapper().
|
private |
List of all readers or writers.
Definition at line 1048 of file ncbimtx.hpp.
Referenced by CRWLock::CRWLock(), CRWLock::ReadLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), CRWLock::Unlock(), CRWLock::WriteLock(), and CRWLock::x_MayAcquireForReading().
|
private |
Platform-dependent RW-lock data.
Definition at line 1044 of file ncbimtx.hpp.
Referenced by CRWLock::ReadLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), CRWLock::Unlock(), and CRWLock::WriteLock().
"this" – to avoid premature destruction
Definition at line 656 of file ncbithr.hpp.
Referenced by CThread::Detach(), CThread::Discard(), CThread::Join(), CThread::Run(), and CThread::Wrapper().
|
private |
System-specific semaphore data.
Definition at line 1418 of file ncbimtx.hpp.
Referenced by CSemaphore::CSemaphore(), CSemaphore::Post(), CSemaphore::TryWait(), CSemaphore::Wait(), and CSemaphore::~CSemaphore().
|
private |
Definition at line 165 of file lock_vector.hpp.
|
private |
Definition at line 164 of file lock_vector.hpp.
Referenced by CLockVectorGuard< TLockVector >::GetTimeout().
|
private |
Type of lock held.
Definition at line 1290 of file ncbimtx.hpp.
Referenced by CYieldingRWLock::x_ReleaseLock().
|
private |
Definition at line 507 of file ncbithr.hpp.
Referenced by CUsedTlsBases::ClearAll(), CUsedTlsBases::Deregister(), and CUsedTlsBases::Register().
|
private |
Flag showing if mutex is locked (non-NULL value) or unlocked (NULL value).
Definition at line 876 of file ncbimtx.hpp.
Referenced by CSpinLock::Lock(), CSpinLock::TryLock(), and CSpinLock::Unlock().
void* CTlsBase::STlsData::m_Value |
Definition at line 129 of file ncbithr.hpp.
Referenced by CTlsBase::CleanupTlsData(), CTlsBase::x_GetValue(), and CTlsBase::x_SetValue().
|
private |
Definition at line 1505 of file ncbimtx.hpp.
Referenced by CConditionVariable::x_WaitForSignal().
|
private |
Number of writers waiting; zero if not keeping track.
Definition at line 1047 of file ncbimtx.hpp.
Referenced by CRWLock::ReadLock(), CRWLock::TryReadLock(), CRWLock::TryWriteLock(), CRWLock::Unlock(), CRWLock::WriteLock(), and CRWLock::x_MayAcquireForReading().
|
private |
Definition at line 1506 of file ncbimtx.hpp.
Referenced by CConditionVariable::x_WaitForSignal().
|
private |
Mutex implementing write lock.
Definition at line 1169 of file ncbimtx.hpp.
Referenced by CFastRWLock::ReadLock(), CFastRWLock::WriteLock(), and CFastRWLock::WriteUnlock().
Definition at line 660 of file ncbithr.hpp.
Referenced by CThread::IsAppExiting(), and CNcbiApplicationAPI::~CNcbiApplicationAPI().
|
staticprivate |
Total amount of threads.
Definition at line 671 of file ncbithr.hpp.
Referenced by CThread::GetThreadsCount(), CThread::Run(), CThread::WaitForAllThreads(), and CThread::Wrapper().
|
staticprivate |
Definition at line 509 of file ncbithr.hpp.
Referenced by CUsedTlsBases::ClearAll(), CUsedTlsBases::ClearAllCurrentThread(), CUsedTlsBases::GetUsedTlsBases(), and CUsedTlsBases::Init().
Definition at line 661 of file ncbithr.hpp.
Referenced by CThread::SetWaitForAllThreadsTimeout(), and CThread::WaitForAllThreads().
|
friend |
Definition at line 377 of file ncbimtx.hpp.
|
friend |
Definition at line 472 of file ncbimtx.hpp.
|
friend |
Definition at line 378 of file ncbimtx.hpp.
|
friend |
Definition at line 473 of file ncbimtx.hpp.
|
friend |
Definition at line 379 of file ncbimtx.hpp.
|
friend |
Definition at line 684 of file ncbithr.hpp.
Definition at line 513 of file ncbithr.hpp.
Definition at line 791 of file ncbithr.hpp.
|
friend |
Definition at line 710 of file ncbimtx.hpp.
|
friend |
Allow use of m_Mtx and m_Owner members directly.
Definition at line 807 of file ncbimtx.hpp.
|
friend |
Definition at line 1317 of file ncbimtx.hpp.
|
friend |
Definition at line 69 of file ncbithr.hpp.
|
friend |
Definition at line 530 of file ncbithr.hpp.
|
friend |
Definition at line 68 of file ncbithr.hpp.
|
friend |
Definition at line 343 of file ncbithr.hpp.
|
friend |
Definition at line 1231 of file ncbimtx.hpp.
|
friend |
Definition at line 376 of file ncbimtx.hpp.
|
friend |
Definition at line 673 of file ncbithr.cpp.