CoreLinux++  0.4.32
Public Member Functions | Protected Member Functions | Friends | List of all members
corelinux::SemaphoreGroup Class Referenceabstract

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...
 
- 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

 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...
 
- 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...
 

Friends

class SemaphoreCommon
 

Additional Inherited Members

- Protected Types inherited from corelinux::Synchronized
typedef GuardGuardPtr
 
typedef const GuardGuardCptr
 
typedef GuardGuardRef
 
typedef const GuardGuardCref
 

Detailed Description

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.

Constructor & Destructor Documentation

corelinux::SemaphoreGroup::SemaphoreGroup ( Short  aSemCount,
Int  Rights = OWNER_ALL 
)
throw (Assertion,
SemaphoreException
)

Default constructor creates a private group semaphores.

Parameters
ShortNumber of semaphores in group
AccessRightsSpecifies access control for group, default is owner only.
Exceptions
Assertionif aCount < 1
SemaphoreExceptionif kernel group create call fails.
See also
corelinux::AccessRights

References corelinux::FAIL_IF_EXISTS, corelinux::Thread::getKernelError(), 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.

Parameters
ShortNumber of semaphores in group, this only has meaning used if failOnExist = true
SemaphoreGroupIdentifiervalid group identifier either through a system call or via another ipc mechanism
AccessRightsSpecifies access control for group
CreateDispositionindicates 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
Exceptions
Assertionif aCount < 1
SemaphoreExceptionfor described states
See also
corelinux::AccessRights

References corelinux::FAIL_IF_EXISTS, corelinux::FAIL_IF_NOTEXISTS, corelinux::Thread::getKernelError(), and corelinux::SemaphoreCommon::groupDefined().

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.

Parameters
ShortNumber of semaphores in group, this only has meaning used if failOnExist = true
Charpointer to Group name
AccessRightsSpecifies access control for group
CreateDispositionindicates 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
Exceptions
Assertionif aCount < 1 or aCount > system defined maximum for group
SemaphoreExceptionfor described states
See also
corelinux::AccessRights

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().

Member Function Documentation

virtual AbstractSemaphorePtr corelinux::SemaphoreGroup::createSemaphore ( void  )
throw (SemaphoreException
)
pure virtual

Create a default semaphore type from group.

Returns
AbstractSemaphore aSem - pointer to created semaphore
Exceptions
SemaphoreExceptionif no sems left in group

Implemented in corelinux::EventSemaphoreGroup, corelinux::GatewaySemaphoreGroup, corelinux::MutexSemaphoreGroup, and corelinux::CoreLinuxGuardGroup.

virtual AbstractSemaphorePtr corelinux::SemaphoreGroup::createSemaphore ( SemaphoreIdentifierRef  aIdentifier,
CreateDisposition  disp = CREATE_OR_REUSE,
bool  Recursive = false,
bool  Balking = false 
)
throw (SemaphoreException
)
pure virtual

Create or open (use) a specific semphore in the group.

Parameters
SemaphoreIdentifieridentifies which semphore id to create or attempt to use
CreateDispositionindicates 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
Recursiveto allow same thread multiple locks
Balkingto allow the semaphore to balk
Returns
AbstractSemaphore aSem - pointer to created or opened semaphore
Exceptions
SemaphoreExceptionif 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.

virtual AbstractSemaphorePtr corelinux::SemaphoreGroup::createSemaphore ( std::string  aName,
CreateDisposition  disp = CREATE_OR_REUSE,
bool  Recursive = false,
bool  Balking = false 
)
throw (SemaphoreException
)
pure virtual

Create or open (use) a specific semphore in the group.

Parameters
stringidentifies which semphore id to create or attempt to use
CreateDispositionindicates 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
Recursiveto allow same thread multiple locks
Balkingto allow the semaphore to balk
Returns
AbstractSemaphore aSem - pointer to created or opened semaphore
Exceptions
SemaphoreExceptionif 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.

virtual void corelinux::SemaphoreGroup::destroySemaphore ( AbstractSemaphorePtr  )
throw (SemaphoreException
)
pure virtual

Destroys a created semaphore from this group.

Parameters
AbstractSemaphorepointer of semaphore to destroy
Exceptions
SemaphoreExceptionif semaphore does not belong to this group

Implemented in corelinux::EventSemaphoreGroup, corelinux::GatewaySemaphoreGroup, corelinux::MutexSemaphoreGroup, and corelinux::CoreLinuxGuardGroup.

SemaphoreGroupIdentifierCref corelinux::SemaphoreGroup::getIdentifier ( void  ) const
inline
Short corelinux::SemaphoreGroup::getSemaphoreCount ( void  ) const

Return the number of semaphores in the group.

Returns
Short Count

References isPrivate().

Referenced by corelinux::CoreLinuxGuardGroup::createSemaphore(), and corelinux::SemaphoreCommon::SemaphoreCommon().

bool corelinux::SemaphoreGroup::isPrivate ( void  ) const
inlineprotected
bool corelinux::SemaphoreGroup::operator== ( SemaphoreGroupCref  aSemGroupRef) const

Equality operator compares the identifier.

Parameters
SemaphoreGroupa reference to SemaphoreGroup
Returns
bool True if equal
void corelinux::SemaphoreGroup::setGroupType ( IntCref  ) const
protected

This indirects to CSA for non-private group types.

Parameters
Intreference to type where 0 = Mutex, 1 = Gateway, 2 = Event, 3-10 reserved. Anything greater than 10 is user defined.

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

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