Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SbThreadAutoSpinlock Class Reference

VSG extension Provides reliable unlocking of a spinlock. More...

#include <Inventor/threads/SbThreadSpinlock.h>

Public Member Functions

 SbThreadAutoSpinlock (SbThreadSpinlock *spinlock)
 Creates a spinlock "autolock" object and automatically calls the mutex lock method.
 
 SbThreadAutoSpinlock (SbThreadSpinlock &spinlock)
 

Detailed Description

VSG extension Provides reliable unlocking of a spinlock.

This class provides reliable unlocking of a spinlock.

An SbThreadMutex object must be created separately. The address of the spinlock object is passed to the constructor, which locks the spinlock and saves a reference to the spinlock object. The autolock object should be created on the stack, so each thread will have its own autolock. The destructor automatically unlocks the spinlock.

Because the autolock object is created on the stack, it avoids the need to explicitly unlock the spinlock at every point of exit from the function (a common source of errors). The spinlock will be unlocked when the autolock goes out of scope.

Example:

// myClass contains a Mutex object named m_mutex
void myClass::someFunction()
{
// m_spinlock is a ptr to an existing SbThreadSpinlock object
SbThreadAutoSpinlock dummyName( m_spinlock );
... other code ...
} // spinlock automatically unlocked
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Provides reliabl...

SEE ALSO

SbThread, SbThreadSpinlock

Definition at line 126 of file SbThreadSpinlock.h.

Constructor & Destructor Documentation

◆ SbThreadAutoSpinlock() [1/2]

SbThreadAutoSpinlock::SbThreadAutoSpinlock ( SbThreadSpinlock spinlock)
inline

Creates a spinlock "autolock" object and automatically calls the mutex lock method.

The spinlock will be automatically unlocked when the autolock object is destroyed.

Definition at line 132 of file SbThreadSpinlock.h.

◆ SbThreadAutoSpinlock() [2/2]

SbThreadAutoSpinlock::SbThreadAutoSpinlock ( SbThreadSpinlock spinlock)
inline

Definition at line 139 of file SbThreadSpinlock.h.


The documentation for this class was generated from the following file: