OpendTect  7.0
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 ()
 
int count () const
 
void lock ()
 
SpinLockoperator= (const SpinLock &b)
 
bool tryLock ()
 
void unLock ()
 

Protected Attributes

Atomic< int > count_
 
Atomic< void * > lockingthread_
 
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

◆ SpinLock() [1/2]

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

◆ SpinLock() [2/2]

Threads::SpinLock::SpinLock ( const SpinLock )

◆ ~SpinLock()

Threads::SpinLock::~SpinLock ( )

Member Function Documentation

◆ count()

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

Only for debugging.

◆ lock()

void Threads::SpinLock::lock ( )

◆ operator=()

SpinLock& Threads::SpinLock::operator= ( const SpinLock b)
inline

◆ tryLock()

bool Threads::SpinLock::tryLock ( )

◆ unLock()

void Threads::SpinLock::unLock ( )

Member Data Documentation

◆ count_

Atomic<int> Threads::SpinLock::count_
protected

◆ lockingthread_

Atomic<void*> Threads::SpinLock::lockingthread_
protected

0 if unlocked, otherwise set to locking thread

◆ recursive_

bool Threads::SpinLock::recursive_
protected

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