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

Search Toolkit Book for CSpinLock

CSpinLock –. More...

#include <corelib/ncbimtx.hpp>

Public Types

typedef CSpinGuard TReadLockGuard
 Define Read Lock Guard. More...
typedef CSpinGuard TWriteLockGuard
 Define Write Lock Guard. More...

Public Member Functions

 CSpinLock (void)
 ~CSpinLock (void)
void Lock (void)
 Lock the mutex. More...
bool TryLock (void)
 Attempt to lock the mutex and return TRUE if it succeeded or FALSE if mutex is locked by other thread. More...
void Unlock (void)
 Unlock the mutex. More...
bool IsLocked (void) const
 Check if mutex is currently locked. More...

Private Member Functions

 CSpinLock (const CSpinLock &)
 Prohibit copying of the object. More...
CSpinLockoperator= (const CSpinLock &)

Private Attributes

void *volatile m_Value
 Flag showing if mutex is locked (non-NULL value) or unlocked (NULL value). More...

Detailed Description

CSpinLock –.

Simple lock with lock/unlock functions even faster than in CFastMutex.

This mutex can be used instead of CFastMutex when it's guaranteed that lock will be always held for a short period of time. CSpinLock doesn't do any system calls to wait for lock acquiring and relies on a fact that a couple of thread reschedulings will be enough for another thread to release the lock. As with CFastMutex no recursive locks are allowed.

Definition at line 842 of file ncbimtx.hpp.

The documentation for this class was generated from the following files:
Modified on Wed Jun 19 17:00:00 2024 by rev. 669887