corelinux::SemaphoreGroup Class Reference

A SemaphoreGroup is an extension to the Linux semaphore set. More...

#include <SemaphoreGroup.hpp>

Inheritance diagram for corelinux::SemaphoreGroup:

corelinux::Synchronized corelinux::CoreLinuxGuardGroup corelinux::EventSemaphoreGroup corelinux::GatewaySemaphoreGroup corelinux::MutexSemaphoreGroup List of all members.

Public Member Functions

 SemaphoreGroup (Short, Int Rights=OWNER_ALL) throw (Assertion,SemaphoreException)
 Default constructor creates a private group semaphores.
 SemaphoreGroup (Short, SemaphoreGroupIdentifierCref, Int, CreateDisposition disp=FAIL_IF_EXISTS) throw (Assertion,SemaphoreException)
 Constructor to open or create a semaphore group with a specific identifier.
 SemaphoreGroup (Short, CharCptr, Int, CreateDisposition disp=FAIL_IF_EXISTS) throw (Assertion,SemaphoreException)
 Constructor to open or create a semaphore group by name.
virtual ~SemaphoreGroup (void)
 Virtual destructor.
bool operator== (SemaphoreGroupCref) const
 Equality operator compares the identifier.
Short getSemaphoreCount (void) const
 Return the number of semaphores in the group.
SemaphoreGroupIdentifierCref getIdentifier (void) const
 Return the SemaphoreGroupIdentifier.
virtual AbstractSemaphorePtr createSemaphore (void)=0 throw ( SemaphoreException )
 Create a default semaphore type from group.
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.
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.
virtual void destroySemaphore (AbstractSemaphorePtr)=0 throw ( SemaphoreException )
 Destroys a created semaphore from this group.

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.
bool isPrivate (void) const
 Internal check for creation visibility.

Friends

class SemaphoreCommon

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  ,
Int  Rights = OWNER_ALL 
) throw (Assertion,SemaphoreException)

Default constructor creates a private group semaphores.

Parameters:
Short Number of semaphores in group
AccessRights Specifies access control for group, default is owner only.
Exceptions:
Assertion if aCount < 1
SemaphoreException if kernel group create call fails.
See also:
corelinux::AccessRights

corelinux::SemaphoreGroup::SemaphoreGroup ( Short  ,
SemaphoreGroupIdentifierCref  ,
Int  ,
CreateDisposition  disp = FAIL_IF_EXISTS 
) throw (Assertion,SemaphoreException)

Constructor to open or create a semaphore group with a specific identifier.

Parameters:
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
Exceptions:
Assertion if aCount < 1
SemaphoreException for described states
See also:
corelinux::AccessRights

corelinux::SemaphoreGroup::SemaphoreGroup ( Short  ,
CharCptr  ,
Int  ,
CreateDisposition  disp = FAIL_IF_EXISTS 
) throw (Assertion,SemaphoreException)

Constructor to open or create a semaphore group by name.

Parameters:
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
Exceptions:
Assertion if aCount < 1 or aCount > system defined maximum for group
SemaphoreException for described states
See also:
corelinux::AccessRights


Member Function Documentation

bool corelinux::SemaphoreGroup::operator== ( SemaphoreGroupCref   )  const

Equality operator compares the identifier.

Parameters:
SemaphoreGroup a reference to SemaphoreGroup
Returns:
bool True if equal

Short corelinux::SemaphoreGroup::getSemaphoreCount ( void   )  const

Return the number of semaphores in the group.

Returns:
Short Count

SemaphoreGroupIdentifierCref corelinux::SemaphoreGroup::getIdentifier ( void   )  const [inline]

Return the SemaphoreGroupIdentifier.

Returns:
SemaphoreGroupIdentifier

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:
SemaphoreException if no sems left in group

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

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:
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
Returns:
AbstractSemaphore aSem - pointer to created or opened semaphore
Exceptions:
SemaphoreException if the disposition disagrees with the semaphore state, or if it is a erroneous identifier

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

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:
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
Returns:
AbstractSemaphore aSem - pointer to created or opened semaphore
Exceptions:
SemaphoreException if the disposition disagrees with the semaphore state, or if it is a erroneous identifier

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

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

Destroys a created semaphore from this group.

Parameters:
AbstractSemaphore pointer of semaphore to destroy
Exceptions:
SemaphoreException if semaphore does not belong to this group

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

void corelinux::SemaphoreGroup::setGroupType ( IntCref   )  const [protected]

This indirects to CSA for non-private group types.

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

bool corelinux::SemaphoreGroup::isPrivate ( void   )  const [inline, protected]

Internal check for creation visibility.

This implies that even though the group may be shared, the user has elected to use privately.


The documentation for this class was generated from the following files:
This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium