Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXSemaphore Class Reference

A semaphore allows for protection of a resource that can be accessed by a fixed number of simultaneous threads. More...

#include <FXSemaphore.h>

List of all members.

Public Member Functions

 FXSemaphore (FXint initial=1)
 Initialize semaphore with given count.
FXint value () const
 Get semaphore value.
void wait ()
 Decrement semaphore, waiting if count is zero.
FXbool trywait ()
 Decrement semaphore; returning false if count is zero.
void post ()
 Increment semaphore.
 ~FXSemaphore ()
 Delete semaphore.

Detailed Description

A semaphore allows for protection of a resource that can be accessed by a fixed number of simultaneous threads.

A typical example of the use of semaphores is for a buffer containing N items. A producer thread may freely append N items before blocking for space to become available; a consumer thread can remove items and block only when no items are left. Thus, two counting semaphores could be used to manage such a buffer, one counting empty slots and one counting filled slots. As long as production and consumption proceed at comparable rates, no thread needs to be suspended.


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

Copyright © 1997-2011 Jeroen van der Zijp