CoreLinux++  0.4.32
Public Member Functions | Protected Member Functions | List of all members
corelinux::Semaphore Class Reference

A Semaphore supports the protocol that processes and/or threads agree to follow for the purpose of controlled access to a resource. More...

#include <Semaphore.hpp>

Public Member Functions

 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.
 
virtual bool isLocked (void)=0
 Ask if AbstractSemaphore instance is locked.
 
virtual SemaphoreOperationStatus lockWithWait (void)=0 throw (SemaphoreException)
 Request the lock, wait for availability.
 
virtual SemaphoreOperationStatus lockWithNoWait (void)=0 throw (SemaphoreException)
 Request the lock without waiting.
 
virtual SemaphoreOperationStatus release (void)=0 throw (SemaphoreException)
 Request the AbstractSemaphore but timeout if not available. More...
 
- 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

 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 GuardGuardPtr
 
typedef const GuardGuardCptr
 
typedef GuardGuardRef
 
typedef const GuardGuardCref
 

Detailed Description

A Semaphore supports the protocol that processes and/or threads agree to follow for the purpose of controlled access to a resource.

The resource can be anything that the developer considers to need access controls on such as memory, hardware, methods, computer instructions, and so on.

Callers can elect to avoid being put into a blocked state and return immediately without control to the resource. Callers may also request that they are put into a blocked state for a specified amount of time. If, at the end of the specified time, the request has not been satisfied, it is returned with a Timeout indicator.

The owner or creator of the semaphore can elect to enforce balking behavior on a Semaphore. When so designated, the Semaphore can turn back any request until some condition in their solution space is met regardless of the callers blocking options. If a caller access attempt is balked, is it returned with a Balked indicator.

Constructor & Destructor Documentation

§ Semaphore()

corelinux::Semaphore::Semaphore ( SemaphoreGroupPtr  aGroup,
SemaphoreIdentifierRef  aIdentifier,
bool  Recursive = false,
bool  Balking = false 
)
throw (NullPointerException
)

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

Parameters
SemaphoreGroupPtrThe owning SemaphoreGroup
SemaphoreIdentifierThe identifier from the Semaphore Group
booltrue if recursion enabled
booltrue if balking enabled

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

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