zeus::TSemaphore Class Reference

#include <Semaphore.h>

Inheritance diagram for zeus::TSemaphore:

zeus::TZObject zeus::IZUnknown

List of all members.

Public Member Functions

 TSemaphore (Uint uiInitValue=0)
 TSemaphore (const TString &rName, Uint uiInitValue=0, bool bOpenExisting=false)
bool acquire ()
bool acquire (Int iPermits)
bool existedAlready () const
void free ()
void free (Int iPermits)
Int getAvailablePermits () const
bool hasError () const
bool isLocked () const
bool isNamed () const
bool tryAcquire ()
bool tryAcquire (const Float &rfTimeOut)

Protected Member Functions

virtual ~TSemaphore ()


Detailed Description

This class wrapps a semaphore kernel-object.

Constructor & Destructor Documentation

TSemaphore::TSemaphore ( Uint  uiInitValue = 0  ) 

Creates a semaphore

Parameters:
uiInitValue : initial value of the semaphore

TSemaphore::TSemaphore ( const TString rName,
Uint  uiInitValue = 0,
bool  bOpenExisting = false 
)

Creates an named semaphore. This is needed if the semaphore is shared between different processes.

Parameters:
rName : Name of the semaphore
uiInitValue : initial value of the semaphore
bOpenExisting : Opens the semaphore only if it exists already

TSemaphore::~TSemaphore (  )  [protected, virtual]

Destroys the semaphore


Member Function Documentation

bool TSemaphore::acquire (  ) 

Acquires a permit. The method fails if a thread tries to terminate.

Return values:
true,: permit is acquired
false,: failed

bool TSemaphore::acquire ( Int  iPermits  ) 

Blocks until all n permits are acquired. This call either aquires all permits or none.

Parameters:
iPermits : numbers of permits
Return values:
true,: all permits are acquired
false,: failed

bool zeus::TSemaphore::existedAlready (  )  const [inline]

checks if the semaphore already existed

void TSemaphore::free (  ) 

release a permit

void zeus::TSemaphore::free ( Int  iPermits  )  [inline]

releases n permits

Int TSemaphore::getAvailablePermits (  )  const

returns the number of available permits

bool zeus::TSemaphore::hasError (  )  const [inline]

returns true if the semaphore has an error

bool zeus::TSemaphore::isLocked (  )  const [inline]

Tests if the semaphore is locked

bool zeus::TSemaphore::isNamed (  )  const [inline]

returns true if the object has been named

bool TSemaphore::tryAcquire (  ) 

tries to acquires a permit. If no permit can be acquired the method returns immediately.

Return values:
true : lock was acquired
false : Could not acquire a lock

bool TSemaphore::tryAcquire ( const Float &  rfTimeOut  ) 

tries to acquires a permit. If no permit can be acquired the method returns after [fTimeOut] secs.

Parameters:
fTimeOut : Time out for waiting for locks
Return values:
true : lock was acquired
false : Could not acquire a lock


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


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Wed Oct 28 21:42:35 2009