UtiLite  0.3.1
A lite utilities library
Public Member Functions
USemaphore Class Reference

#include <USemaphore.h>

List of all members.

Public Member Functions

 USemaphore (int initValue=0)
void acquire (int n=1)
void release (int n=1)
int value ()

Detailed Description

A semaphore class.

On an acquire() call, the calling thread is blocked if the USemaphore's value is <= 0. It is unblocked when release() is called. The function acquire() decreases by 1 (default) the semaphore's value and release() increases it by 1 (default).

Example:

 USemaphore s;
 s.acquire(); // Will wait until s.release() is called by another thread.
See also:
UMutex

Constructor & Destructor Documentation

USemaphore::USemaphore ( int  initValue = 0) [inline]

The constructor. The semaphore waits on acquire() when its value is <= 0.

Parameters:
nnumber to initialize

Member Function Documentation

void USemaphore::acquire ( int  n = 1) [inline]

Acquire the semaphore. If semaphore's value is <=0, the calling thread will wait until the count acquired is released.

See also:
release()
Parameters:
nnumber to acquire
void USemaphore::release ( int  n = 1) [inline]

Release the semaphore, increasing its value by 1 and signaling waiting threads (which called acquire()).

int USemaphore::value ( ) [inline]

Get the USempahore's value.

Returns:
the semaphore's value

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Friends Defines