SbThreadSemaphore Class Reference
[Threads]

Semaphore management. More...

#include <Inventor/threads/SbThreadSemaphore.h>

List of all members.

Public Member Functions

 SbThreadSemaphore (int initialCount, int maxCount=-1)
 ~SbThreadSemaphore ()
void wait ()
SbBool trywait (const unsigned int timeout_ms=0)
void release ()
void changeCount (int)

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


Constructor & Destructor Documentation

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

Destructor.


Member Function Documentation

void SbThreadSemaphore::changeCount ( int   ) 

Allows adding or removing resources.

void SbThreadSemaphore::release (  ) 

Releases the semaphore.

This call increases the semaphore count.

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.

void SbThreadSemaphore::wait (  ) 

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

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/