Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SbThreadSemaphore Class Reference

Semaphore management. More...

#include <Inventor/threads/SbThreadSemaphore.h>

Public Member Functions

 SbThreadSemaphore (int initialCount, int maxCount=-1)
 Semaphore constructor.
 
 ~SbThreadSemaphore ()
 Destructor.
 
void wait ()
 
SbBool trywait (const unsigned int timeout_ms=0)
 Try to acquire the semaphore.
 
void release ()
 Releases the semaphore.
 
void changeCount (int)
 Allows adding or removing resources.
 

Detailed Description

Semaphore management.

VSG extension

Class managing a semaphore. A semaphore is a non-negative integer count and is generally used to coordinate access to resources. The initial semaphore count is set to the number of free resources, then threads slowly increment and decrement the count as resources are added and removed. If the semaphore count drops to zero, which means no available resources, threads attempting to decrement the semaphore will block until the count is greater than zero.

SEE ALSO

Definition at line 50 of file SbThreadSemaphore.h.

Constructor & Destructor Documentation

◆ SbThreadSemaphore()

SbThreadSemaphore::SbThreadSemaphore ( int  initialCount,
int  maxCount = -1 
)

Semaphore constructor.

MaxCount is the maximum count of the counter. If maxCount isn't specified (=-1), it will be initialized to initialCount. If maxCount is set to -2 it will be initialized to maximum value allowed by the system (unlimited semaphore behavior).

◆ ~SbThreadSemaphore()

SbThreadSemaphore::~SbThreadSemaphore ( )

Destructor.

Member Function Documentation

◆ changeCount()

void SbThreadSemaphore::changeCount ( int  )

Allows adding or removing resources.

◆ release()

void SbThreadSemaphore::release ( )

Releases the semaphore.

This call increases the semaphore count.

◆ trywait()

SbBool SbThreadSemaphore::trywait ( const unsigned int  timeout_ms = 0)

Try to acquire the semaphore.

If the semaphore count drops to zero, which means no available resources, the thread attempting to decrement the semaphore will block until the count is greater than zero (meaning that another thread called release).

The time out parameter specifies how many milliseconds to wait before checking for release of the semaphore. By default there is no wait.

◆ wait()

void SbThreadSemaphore::wait ( )

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