SbThreadMutex Class Reference
[Threads]

VSG extension Portable mutex class. More...

#include <Inventor/threads/SbThreadMutex.h>

List of all members.

Public Member Functions

 SbThreadMutex ()
int lock ()
int unlock ()
SbBool trylock ()

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


Constructor & Destructor Documentation

SbThreadMutex::SbThreadMutex (  ) 

Creates a mutex.

SoDEPRECATED SbThreadMutex::SbThreadMutex ( const SbBool  force  ) 
Deprecated:

Deprecated since Open Inventor 10000
The 'force' parameter is no longer used. The default constructor should be used instead.

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 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/