corelinux::EventSemaphore Class Reference

EventSemaphore implements a way to queue its caller until a certain event takes place. More...

`#include <EventSemaphore.hpp>`

## Public Member Functions

| EventSemaphore (SemaphoreGroupPtr aGroup, SemaphoreIdentifierRef aIdentifier, Counter aLimit, bool aRecursionFlag=true, bool aBalkingFlag=false) throw ( NullPointerException )
| Default constructor requires the identifier of the semaphore in the semaphore group. More...
virtual | ~EventSemaphore (void)
| Virtual Destructor.
virtual bool | isLocked (void)
| Check if semaphore instance is locked.
SemaphoreOperationStatus | post (void) throw ( SemaphoreException )
| Indicate owner commitment to trigger the event after a finite amount of time.
virtual SemaphoreOperationStatus | lockWithWait (void) throw ( SemaphoreException )
| Wait for the event associated with this semaphore to take place. More...
virtual SemaphoreOperationStatus | lockWithNoWait (void) throw ( SemaphoreException )
| Check if the associated event has taken place.
virtual SemaphoreOperationStatus | release (void) throw ( SemaphoreException )
| Request the semaphore but timeout if not available. More...
virtual void | setLimit (Counter aLimit) throw ( SemaphoreException )
| Set the maximum number of listeners allowed on this semaphore. More...
virtual Counter | getLimit (void) const
| Get the maximum number of listeners of this semaphore.
Public Member Functions inherited from corelinux::Semaphore
| Semaphore (SemaphoreGroupPtr, SemaphoreIdentifierRef, bool Recursive=false, bool Balking=false) throw ( NullPointerException )
| Default constructor requires the identifier of the semaphore in the semaphore group. More...
virtual | ~Semaphore (void)
| Virtual Destructor.
bool | operator== (SemaphoreCref aRef) const
| Equality operator returns true if identifiers match.
virtual bool | isBalkingEnabled (void) const
| Returns true if balking enabled.
virtual bool | isRecursionEnabled (void) const
| Returns true if recursion allowed.
virtual ThreadIdentifierCref | getOwningThreadIdentifier (void) const
| Returns the identifier of who currently owns the semaphore.
virtual CounterCref | getRecursionQueueLength (void) const
| Return the depth of the recursion for the owner.
Public Member Functions inherited from corelinux::AbstractSemaphore
| AbstractSemaphore (SemaphoreGroupPtr, SemaphoreIdentifierRef) throw ( NullPointerException )
| Default constructor.
virtual | ~AbstractSemaphore (void)
| Virtual Destructor.
bool | operator== (AbstractSemaphoreCref aRef) const
| Equality operator returns true if identifiers match.
SemaphoreIdentifierCref | getIdentifier (void) const
| Return a reference to this AbstractSemaphore identifier.
SemaphoreGroupIdentifierCref | getGroupIdentifier (void) const
| Returns a reference to the SemaphoreGroup identifier.
Int | getValue (void)
| Returns the current value of the semaphore.
Int | getInitialValue (void)
| Retrieves the initial value for a semaphore.
Public Member Functions inherited from corelinux::Synchronized
| Synchronized (void)
| Default constructor.
| Synchronized (SynchronizedCref)
| Copy constructor.
virtual | ~Synchronized (void)
| Virtual Destructor.
SynchronizedRef | operator= (SynchronizedCref)
| Assignment operator.
bool | operator== (SynchronizedCref) const
| Equality operator.

## Protected Member Functions

| EventSemaphore (void) throw ( Assertion )
| Default constructor throws assert.
| EventSemaphore (EventSemaphoreCref) throw ( Assertion )
| Copy constructor throws assertion.
EventSemaphoreRef | operator= (EventSemaphoreCref) throw ( Assertion )
| Assignment operator throws assertion.
Protected Member Functions inherited from corelinux::Semaphore
| Semaphore (void) throw (Assertion)
| Default constructor throws assertion.
| Semaphore (SemaphoreCref) throw (Assertion)
| Copy constructor throws assertion.
SemaphoreRef | operator= (SemaphoreCref) throw (Assertion)
| Assignment operator throws assertion.
CounterCref | operator++ (void)
| Operator for increasing theRecursionQueueLength.
CounterCref | operator-- (void)
| Operator for decreasing theRecursionQueueLength.
virtual ThreadIdentifierRef | getOwnerId (void)
| Returns a reference to the owning thread.
virtual void | setOwnerId (void)
| Sets the owner id to the current thread.
virtual void | setRecursionQueueLength (Counter)
| Sets the recursion length.
virtual void | resetOwnerId (void)
| Sets the owner thread id to not owned.
Protected Member Functions inherited from corelinux::AbstractSemaphore
| AbstractSemaphore (AbstractSemaphoreCref) throw (Assertion)
AbstractSemaphoreRef | operator= (AbstractSemaphoreCref) throw (Assertion)
SemaphoreIdentifierRef | getId (void)
| Returns a reference to the AbstractSemaphore identifier.
Int | getGroupId (void) const
| Returns a reference to the group identifier.
SemaphoreOperationStatus | setLock (Int)
| Calls kernel lock mechanism.
SemaphoreOperationStatus | setUnlock (Int)
| Calls kernel unlock mechanism.
SemaphoreOperationStatus | waitZero (Int)
| Calls kernel zero mechanism.
SemaphoreOperationStatus | setValue (Int)
| Sets the value for the AbstractSemaphore.
Protected Member Functions inherited from corelinux::Synchronized
Guard | access (void) const throw (SemaphoreException)
| Access returns a instance of Guard which is block scoped to the caller. More...

## Additional Inherited Members

Protected Types inherited from corelinux::Synchronized
typedef Guard * | GuardPtr
typedef const Guard * | GuardCptr
typedef Guard & | GuardRef
typedef const Guard & | GuardCref

## Detailed Description

EventSemaphore implements a way to queue its caller until a certain event takes place.

## Constructor & Destructor Documentation

corelinux::EventSemaphore::EventSemaphore | ( | SemaphoreGroupPtr | aGroup,
|  | SemaphoreIdentifierRef | aIdentifier,
|  | Counter | aLimit,
|  | bool | aRecursionFlag = `true`,
|  | bool | aBalkingFlag = `false`
| ) |  |
throw | ( | NullPointerException
| ) |  |

Default constructor requires the identifier of the semaphore in the semaphore group.

Parameters

  aGroup | pointer to the owning SemaphoreGroup
  aIdentifier | The identifier for the Semaphore from the SemaphoreGroup

  aLimit

  the maximum number of listeners.
  - aLimit < 0 : infinite number of listeners,
  - aLimit >= 0 : finite number of listeners

  Recursive | true if recursion enabled
  Balking | true if balking enabled

References corelinux::Semaphore::setOwnerId(), and corelinux::AbstractSemaphore::setValue().

## Member Function Documentation

SemaphoreOperationStatus corelinux::EventSemaphore::lockWithWait | ( | void |  | ) |
throw | ( | SemaphoreException
| ) |  |

virtual

Wait for the event associated with this semaphore to take place.

Block if the event has not occured

Implements corelinux::AbstractSemaphore.

References corelinux::Synchronized::access(), corelinux::BALKED, corelinux::Semaphore::isBalkingEnabled(), isLocked(), corelinux::Synchronized::Guard::release(), corelinux::SUCCESS, corelinux::UNAVAILABLE, and corelinux::AbstractSemaphore::waitZero().

SemaphoreOperationStatus corelinux::EventSemaphore::release | ( | void |  | ) |
throw | ( | SemaphoreException
| ) |  |

virtual

Request the semaphore but timeout if not available.

Signal the observer that an event has occured.

Implements corelinux::AbstractSemaphore.

References corelinux::AbstractSemaphore::setLock(), and corelinux::SUCCESS.

void corelinux::EventSemaphore::setLimit | ( | Counter | aLimit | ) |
throw | ( | SemaphoreException
| ) |  |

virtual

Set the maximum number of listeners allowed on this semaphore.

Parameters

  aLimit

  the maximum number of listeners.
  - aLimit < 0: infinite number of listeners,
  - aLimit >= 0: finite number of listeners,

References corelinux::Semaphore::getOwnerId(), and corelinux::Thread::getThreadIdentifier().

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

- EventSemaphore.hpp
- EventSemaphore.cpp

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium