SbThreadMutex Class Reference

VSG extension Portable mutex class. More...

#include <Inventor/threads/SbThreadMutex.h>

List of all members.

Public Member Functions

 SbThreadMutex (const SbBool force=FALSE)
int lock ()
int unlock ()
SbBool trylock ()

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.)


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

Constructor & Destructor Documentation

SbThreadMutex::SbThreadMutex ( const SbBool  force = FALSE  ) 

Creates a mutex.

Member Function Documentation

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.

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.

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.

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

Open Inventor Toolkit reference manual, generated on 22 Sep 2021
Copyright © Thermo Fisher Scientific All rights reserved.