OpendTect-6_4  6.4
Public Member Functions | Protected Attributes | List of all members
Threads::SpinLock Class Reference

Is an alternative to Mutex. It is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available. Because they avoid overhead from operating system process re-scheduling or context switching, spinlocks are efficient if threads are only likely to be blocked for a short period. More...

Public Member Functions

 SpinLock (bool recursive=false)
 
 SpinLock (const SpinLock &)
 
 ~SpinLock ()
 
SpinLockoperator= (const SpinLock &b)
 
void lock ()
 
void unLock ()
 
bool tryLock ()
 
int count () const
 

Protected Attributes

AtomicPointer< const void > lockingthread_
 
int count_
 
bool recursive_
 

Detailed Description

Is an alternative to Mutex. It is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available. Because they avoid overhead from operating system process re-scheduling or context switching, spinlocks are efficient if threads are only likely to be blocked for a short period.

Constructor & Destructor Documentation

Threads::SpinLock::SpinLock ( bool  recursive = false)
Threads::SpinLock::SpinLock ( const SpinLock )
Threads::SpinLock::~SpinLock ( )

Member Function Documentation

int Threads::SpinLock::count ( ) const
inline

Only for debugging.

void Threads::SpinLock::lock ( )
SpinLock& Threads::SpinLock::operator= ( const SpinLock b)
inline
bool Threads::SpinLock::tryLock ( )
void Threads::SpinLock::unLock ( )

Member Data Documentation

int Threads::SpinLock::count_
protected
AtomicPointer<const void> Threads::SpinLock::lockingthread_
protected

0 if unlocked, otherwise set to locking thread

bool Threads::SpinLock::recursive_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019