class Semaphore

Semaphore implementation. More...

Full nameTelEngine::Semaphore
Definition#include <yateclass.h>
InheritsTelEngine::Lockable [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods


Detailed Description

A semaphore object for synchronizing threads, can also be used as a token bucket

explicit  Semaphore (unsigned int maxcount = 1, const char* name = 0)

Semaphore

Construct a new unlocked semaphore

Parameters:
maxcountMaximum unlock count, must be strictly positive
nameStatic name of the semaphore (for debugging purpose only)

 Semaphore (const Semaphore& original)

Semaphore

Copy constructor, creates a shared semaphore

Parameters:
originalReference of the semaphore to share

 ~Semaphore ()

~Semaphore

Destroy the semaphore

Semaphore&  operator= (const Semaphore& original)

operator=

Assignment operator makes the semaphore shared with the original

Parameters:
originalReference of the semaphore to share

bool  lock (long maxwait = -1)

lock

[virtual]

Attempt to get a lock on the semaphore and eventually wait for it

Parameters:
maxwaitTime in microseconds to wait, -1 wait forever

Returns: True if successfully locked, false on failure

Reimplemented from Lockable.

bool  unlock ()

unlock

[virtual]

Unlock the semaphore, does never wait nor get over counter maximum

Returns: True if successfully unlocked

Reimplemented from Lockable.

bool  locked ()

locked

[const virtual]

Check if the semaphore is currently locked (waiting) - as it's asynchronous it guarantees nothing if other thread changes status

Returns: True if the semaphore was locked when the function was called

Reimplemented from Lockable.

int  count ()

count

[static]

Get the number of semaphores counting the shared ones only once

Returns: Count of individual semaphores

int  locks ()

locks

[static]

Get the number of currently locked (waiting) semaphores

Returns: Count of locked semaphores, should be zero at program exit

bool  efficientTimedLock ()

efficientTimedLock

[static]

Check if a timed lock() is efficient on this platform

Returns: True if a lock with a maxwait parameter is efficiently implemented


Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.