Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SbThreadMutex Class Reference

VSG extension Portable mutex class. More...

#include <Inventor/threads/SbThreadMutex.h>

Public Member Functions

 SbThreadMutex ()
 Creates a mutex.
 
int lock ()
 Locks the current thread on this mutex.
 
int unlock ()
 Relinquishes ownership of this mutex.
 
SbBool trylock ()
 Does basically the same as lock, but when a thread tries to gain ownership of this mutex and fails because another thread has already taken ownership of this mutex, trylock() returns FALSE and no lock is actually done.
 
Deprecated
SoDEPRECATED SbThreadMutex (const SbBool force)
 

Detailed Description

VSG extension Portable mutex class.

This class provides a portable mutex. It is implemented using the pthreads API on UNIX/Linux and the Win32 API on Microsoft Windows.

A mutex can be used to protect access to critical data or code that is used by multiple threads.

It is not necessary to use this class in order to use multiple threads with Open Inventor. It is provided only as a convenience. (However, note that you should use pthreads on UNIX/Linux and Win32 on Windows to be certain of compatibility with Open Inventor.)

SEE ALSO

SbThread, SbThreadAutoLock, SbThreadAutoReadLock, SbThreadAutoWriteLock, SbThreadBarrier, SbThreadRWMutex, SbThreadSemaphore, SbThreadSignal

Definition at line 65 of file SbThreadMutex.h.

Constructor & Destructor Documentation

◆ SbThreadMutex() [1/2]

SbThreadMutex::SbThreadMutex ( )

Creates a mutex.

◆ SbThreadMutex() [2/2]

SoDEPRECATED SbThreadMutex::SbThreadMutex ( const SbBool  force)

Member Function Documentation

◆ lock()

int SbThreadMutex::lock ( )
inline

Locks the current thread on this mutex.

If no other thread has already locked this mutex, the current thread takes ownership of this mutex and can enter inside the mutually exclusive area. Note that the same thread can safely call lock() repeatedly, but will have to call unlock() the same number of times in order to relinquish ownership of this mutex. If another thread is already owner of this mutex, the current thread is blocked until the thread owner relinquishes the mutex through unlock(). If several threads are blocked, only one is unblocked. Returns 0 if successful.

Definition at line 92 of file SbThreadMutex.h.

◆ trylock()

SbBool SbThreadMutex::trylock ( )
inline

Does basically the same as lock, but when a thread tries to gain ownership of this mutex and fails because another thread has already taken ownership of this mutex, trylock() returns FALSE and no lock is actually done.

Otherwise, trylock() returns TRUE and the current thread will have at some point to call unlock to relinquish ownership of the mutex.

Definition at line 112 of file SbThreadMutex.h.

◆ unlock()

int SbThreadMutex::unlock ( )
inline

Relinquishes ownership of this mutex.

If the current thread is owner of this mutex (through a call to lock()), unlock() releases the mutex and unblocks one thread waiting for this mutex to be released. If lock() has been called several times, unlock() must be called the same number of times to actually unlock the mutex. Returns 0 if successful.

Definition at line 102 of file SbThreadMutex.h.


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