CoreLinux++
0.4.32
|
A SemaphoreGroup is an extension to the Linux semaphore set. More...
#include <SemaphoreGroup.hpp>
Public Member Functions | |
SemaphoreGroup (Short, Int Rights=OWNER_ALL) throw (Assertion,SemaphoreException) | |
Default constructor creates a private group semaphores. More... | |
SemaphoreGroup (Short, SemaphoreGroupIdentifierCref, Int, CreateDisposition disp=FAIL_IF_EXISTS) throw (Assertion,SemaphoreException) | |
Constructor to open or create a semaphore group with a specific identifier. More... | |
SemaphoreGroup (Short, CharCptr, Int, CreateDisposition disp=FAIL_IF_EXISTS) throw (Assertion,SemaphoreException) | |
Constructor to open or create a semaphore group by name. More... | |
virtual | ~SemaphoreGroup (void) |
Virtual destructor. | |
bool | operator== (SemaphoreGroupCref) const |
Equality operator compares the identifier. More... | |
Short | getSemaphoreCount (void) const |
Return the number of semaphores in the group. More... | |
SemaphoreGroupIdentifierCref | getIdentifier (void) const |
Return the SemaphoreGroupIdentifier. More... | |
virtual AbstractSemaphorePtr | createSemaphore (void)=0 throw ( SemaphoreException ) |
Create a default semaphore type from group. More... | |
virtual AbstractSemaphorePtr | createSemaphore (SemaphoreIdentifierRef aIdentifier, CreateDisposition disp=CREATE_OR_REUSE, bool Recursive=false, bool Balking=false)=0 throw ( SemaphoreException ) |
Create or open (use) a specific semphore in the group. More... | |
virtual AbstractSemaphorePtr | createSemaphore (std::string aName, CreateDisposition disp=CREATE_OR_REUSE, bool Recursive=false, bool Balking=false)=0 throw ( SemaphoreException ) |
Create or open (use) a specific semphore in the group. More... | |
virtual void | destroySemaphore (AbstractSemaphorePtr)=0 throw ( SemaphoreException ) |
Destroys a created semaphore from this group. More... | |
![]() | |
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 | |
SemaphoreGroup (void) throw ( Assertion ) | |
Default constructor not allowed. | |
SemaphoreGroup (SemaphoreGroupCref) throw ( Assertion ) | |
Copy constructor not allowed. | |
SemaphoreGroupRef | operator= (SemaphoreGroupCref) throw ( Assertion ) |
Assignment operator not allowed. | |
void | setGroupType (IntCref) const |
This indirects to CSA for non-private group types. More... | |
bool | isPrivate (void) const |
Claim an unused semaphore from the group. More... | |
![]() | |
Guard | access (void) const throw (SemaphoreException) |
Access returns a instance of Guard which is block scoped to the caller. More... | |
Friends | |
class | SemaphoreCommon |
Additional Inherited Members | |
![]() | |
typedef Guard * | GuardPtr |
typedef const Guard * | GuardCptr |
typedef Guard & | GuardRef |
typedef const Guard & | GuardCref |
A SemaphoreGroup is an extension to the Linux semaphore set.
This provides a way to logically group semaphores. A SemaphoreGroup acts as a Semaphore factory, creating and destroying Semaphores for the user.
corelinux::SemaphoreGroup::SemaphoreGroup | ( | Short | aSemCount, |
Int | Rights = OWNER_ALL |
||
) | |||
throw | ( | Assertion, | |
SemaphoreException | |||
) |
Default constructor creates a private group semaphores.
Short | Number of semaphores in group |
AccessRights | Specifies access control for group, default is owner only. |
Assertion | if aCount < 1 |
SemaphoreException | if kernel group create call fails. |
References corelinux::FAIL_IF_EXISTS, corelinux::Thread::getKernelError(), SemaphoreGroup(), and corelinux::Environment::setupCommonAccess().
corelinux::SemaphoreGroup::SemaphoreGroup | ( | Short | aSemCount, |
SemaphoreGroupIdentifierCref | aGID, | ||
Int | aRightSet, | ||
CreateDisposition | disp = FAIL_IF_EXISTS |
||
) | |||
throw | ( | Assertion, | |
SemaphoreException | |||
) |
Constructor to open or create a semaphore group with a specific identifier.
Short | Number of semaphores in group, this only has meaning used if failOnExist = true |
SemaphoreGroupIdentifier | valid group identifier either through a system call or via another ipc mechanism |
AccessRights | Specifies access control for group |
CreateDisposition | indicates how to treat the conditions that the group may meet in the request: CREATE_OR_REUSE indicates that the caller doesn't care FAIL_IF_EXISTS indicates the attempt was for a create FAIL_IF_NOTEXISTS indicates the attempt was for a open |
Assertion | if aCount < 1 |
SemaphoreException | for described states |
References corelinux::FAIL_IF_EXISTS, corelinux::FAIL_IF_NOTEXISTS, corelinux::Thread::getKernelError(), corelinux::SemaphoreCommon::groupDefined(), and SemaphoreGroup().
corelinux::SemaphoreGroup::SemaphoreGroup | ( | Short | aSemCount, |
CharCptr | aName, | ||
Int | aRightSet, | ||
CreateDisposition | disp = FAIL_IF_EXISTS |
||
) | |||
throw | ( | Assertion, | |
SemaphoreException | |||
) |
Constructor to open or create a semaphore group by name.
Short | Number of semaphores in group, this only has meaning used if failOnExist = true |
Char | pointer to Group name |
AccessRights | Specifies access control for group |
CreateDisposition | indicates how to treat the conditions that the group may meet in the request: CREATE_OR_REUSE indicates that the caller doesn't care FAIL_IF_EXISTS indicates the attempt was for a create FAIL_IF_NOTEXISTS indicates the attempt was for a open |
Assertion | if aCount < 1 or aCount > system defined maximum for group |
SemaphoreException | for described states |
References corelinux::CREATE_OR_REUSE, corelinux::FAIL_IF_EXISTS, corelinux::FAIL_IF_NOTEXISTS, corelinux::Thread::getKernelError(), corelinux::SemaphoreCommon::groupDefined(), corelinux::Environment::removeCommonAccess(), and corelinux::Environment::setupCommonAccess().
|
pure virtual |
Create a default semaphore type from group.
SemaphoreException | if no sems left in group |
Implemented in corelinux::EventSemaphoreGroup, corelinux::GatewaySemaphoreGroup, corelinux::MutexSemaphoreGroup, and corelinux::CoreLinuxGuardGroup.
|
pure virtual |
Create or open (use) a specific semphore in the group.
SemaphoreIdentifier | identifies which semphore id to create or attempt to use |
CreateDisposition | indicates how to treat the conditions that the group may meet in the request: CREATE_OR_REUSE indicates that the caller doesn't care FAIL_IF_EXISTS indicates the attempt was for a create FAIL_IF_NOTEXISTS indicates the attempt was for a open |
Recursive | to allow same thread multiple locks |
Balking | to allow the semaphore to balk |
SemaphoreException | if the disposition disagrees with the semaphore state, or if it is a erroneous identifier |
Implemented in corelinux::EventSemaphoreGroup, corelinux::MutexSemaphoreGroup, corelinux::GatewaySemaphoreGroup, and corelinux::CoreLinuxGuardGroup.
|
pure virtual |
Create or open (use) a specific semphore in the group.
string | identifies which semphore id to create or attempt to use |
CreateDisposition | indicates how to treat the conditions that the group may meet in the request: CREATE_OR_REUSE indicates that the caller doesn't care FAIL_IF_EXISTS indicates the attempt was for a create FAIL_IF_NOTEXISTS indicates the attempt was for a open |
Recursive | to allow same thread multiple locks |
Balking | to allow the semaphore to balk |
SemaphoreException | if the disposition disagrees with the semaphore state, or if it is a erroneous identifier |
Implemented in corelinux::EventSemaphoreGroup, corelinux::GatewaySemaphoreGroup, corelinux::MutexSemaphoreGroup, and corelinux::CoreLinuxGuardGroup.
|
pure virtual |
Destroys a created semaphore from this group.
AbstractSemaphore | pointer of semaphore to destroy |
SemaphoreException | if semaphore does not belong to this group |
Implemented in corelinux::EventSemaphoreGroup, corelinux::GatewaySemaphoreGroup, corelinux::MutexSemaphoreGroup, and corelinux::CoreLinuxGuardGroup.
|
inline |
Return the SemaphoreGroupIdentifier.
References corelinux::CREATE_OR_REUSE.
Referenced by corelinux::AbstractSemaphore::AbstractSemaphore(), corelinux::CoreLinuxGuardGroup::destroySemaphore(), corelinux::GatewaySemaphoreGroup::destroySemaphore(), corelinux::MutexSemaphoreGroup::destroySemaphore(), corelinux::EventSemaphoreGroup::destroySemaphore(), corelinux::SemaphoreCommon::registerGroup(), and corelinux::SemaphoreCommon::SemaphoreCommon().
Short corelinux::SemaphoreGroup::getSemaphoreCount | ( | void | ) | const |
Return the number of semaphores in the group.
References isPrivate().
Referenced by corelinux::GatewaySemaphoreGroup::createCountSemaphore(), corelinux::MutexSemaphoreGroup::createLockedSemaphore(), corelinux::CoreLinuxGuardGroup::createSemaphore(), corelinux::GatewaySemaphoreGroup::createSemaphore(), corelinux::MutexSemaphoreGroup::createSemaphore(), corelinux::EventSemaphoreGroup::createSemaphore(), corelinux::EventSemaphoreGroup::destroySemaphore(), corelinux::MutexSemaphoreGroup::resolveSemaphore(), corelinux::GatewaySemaphoreGroup::resolveSemaphore(), and corelinux::SemaphoreCommon::SemaphoreCommon().
|
inlineprotected |
Claim an unused semaphore from the group.
This implies that even though the group may be shared, the user has elected to use privately.Internal check for creation visibility
Referenced by getSemaphoreCount(), corelinux::SemaphoreCommon::getSemaphoreMaxValue(), corelinux::SemaphoreCommon::obtainSemaphore(), corelinux::SemaphoreCommon::relinquishSemaphore(), corelinux::SemaphoreCommon::setLock(), corelinux::SemaphoreCommon::setMaxValue(), corelinux::SemaphoreCommon::setUnLock(), and corelinux::SemaphoreCommon::waitZero().
bool corelinux::SemaphoreGroup::operator== | ( | SemaphoreGroupCref | aSemGroupRef | ) | const |
Equality operator compares the identifier.
SemaphoreGroup | a reference to SemaphoreGroup |
|
protected |
This indirects to CSA for non-private group types.
Int | reference to type where 0 = Mutex, 1 = Gateway, 2 = Event, 3-10 reserved. Anything greater than 10 is user defined. |