CoreLinux++
0.4.32
|
MutexSemaphore implements a mutual exclusion control which can be used to insure that at most one (1) task has access at a time. More...
#include <MutexSemaphore.hpp>
Public Member Functions | |
MutexSemaphore (SemaphoreGroupPtr, SemaphoreIdentifierRef, bool AutoLock=false, bool Recursive=true, bool Balking=false) throw ( NullPointerException ) | |
Default constructor requires the identifier of the semaphore in the semaphore group. More... | |
virtual | ~MutexSemaphore (void) |
Virtual Destructor. | |
virtual bool | isLocked (void) |
Ask if semaphore instance is locked. | |
virtual SemaphoreOperationStatus | lockWithWait (void) throw (SemaphoreException) |
Request the semaphore, wait for availability. | |
virtual SemaphoreOperationStatus | lockWithNoWait (void) throw (SemaphoreException) |
Request the semaphore without waiting. | |
virtual SemaphoreOperationStatus | release (void) throw (SemaphoreException) |
Request the semaphore but timeout if not available. More... | |
![]() | |
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. | |
![]() | |
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. | |
![]() | |
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 | |
MutexSemaphore (void) throw ( Assertion ) | |
Default construct throws assert. | |
throw (Assertion) | |
Copy constructor throws assertion. | |
MutexSemaphoreRef | operator= (MutexSemaphoreCref) throw ( Assertion ) |
Assignment operator throws assertion. | |
![]() | |
throw (Assertion) | |
Default constructor throws assertion. | |
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. | |
![]() | |
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. | |
![]() | |
Guard | access (void) const throw (SemaphoreException) |
Access returns a instance of Guard which is block scoped to the caller. More... | |
Additional Inherited Members | |
![]() | |
typedef Guard * | GuardPtr |
typedef const Guard * | GuardCptr |
typedef Guard & | GuardRef |
typedef const Guard & | GuardCref |
MutexSemaphore implements a mutual exclusion control which can be used to insure that at most one (1) task has access at a time.
The semantics for Recursion: The thread that is successful is obtaining the lock will be regarded as theOwningThreadIdentifier. If, upon a lock request, it is determined that the same thread that owns the lock is asking to lock again, theRecursionQueueLength will be incremented. It is thereafter neccessary for theOwningThread to release the semaphore until theRecursionQueueLength returns to zero (0). All other callers will block or not based on their lock call disposition.
corelinux::MutexSemaphore::MutexSemaphore | ( | SemaphoreGroupPtr | aGroup, |
SemaphoreIdentifierRef | aIdentifier, | ||
bool | AutoLock = false , |
||
bool | Recursive = true , |
||
bool | Balking = false |
||
) | |||
throw | ( | NullPointerException | |
) |
Default constructor requires the identifier of the semaphore in the semaphore group.
SemaphoreGroup | pointer to the owning SemaphoreGroup |
SemaphoreIdentifier | The identifier for the Semaphore from the SemaphoreGroup |
bool | true if autolock on creation |
bool | true if recursion enabled |
bool | true if balking enabled |
References corelinux::Semaphore::setOwnerId().
|
virtual |
Request the semaphore but timeout if not available.
Release the semaphore if owner
Implements corelinux::AbstractSemaphore.
References corelinux::Semaphore::getOwnerId(), corelinux::Semaphore::getRecursionQueueLength(), corelinux::Thread::getThreadIdentifier(), corelinux::Semaphore::resetOwnerId(), corelinux::AbstractSemaphore::setUnlock(), corelinux::SUCCESS, and corelinux::UNAVAILABLE.