SemaphoreGroup.hpp
#if !defined(__SEMAPHOREGROUP_HPP)
#define __SEMAPHOREGROUP_HPP
/*
CoreLinux++
Copyright (C) 1999,2000 CoreLinux Consortium
The CoreLinux++ Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The CoreLinux++ Library Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#if !defined(__COMMON_HPP)
#include <Common.hpp>
#endif
#if !defined(__SEMAPHORECOMMON_HPP)
#include <SemaphoreCommon.hpp>
#endif
#if !defined(__ABSTRACTSEMAPHORE_HPP)
#include <AbstractSemaphore.hpp>
#endif
#if !defined(__MAP_HPP)
#include <Map.hpp>
#endif
namespace corelinux
{
const Dword NAMEBUFFERSIZE(254);
struct SemaphoreReference
{
Int theCount;
AbstractSemaphorePtr theSem;
};
CORELINUX_MAP( Index, SemaphoreReference, std::less<Index> , SemaphoreShares );
DECLARE_CLASS( SemaphoreGroup );
class SemaphoreGroup : public Synchronized
{
public:
SemaphoreGroup( Short , Int Rights = OWNER_ALL )
throw(Assertion,SemaphoreException);
SemaphoreGroup
(
Short,
SemaphoreGroupIdentifierCref,
Int ,
CreateDisposition disp=FAIL_IF_EXISTS
) throw(Assertion,SemaphoreException);
SemaphoreGroup
(
Short,
CharCptr,
Int ,
CreateDisposition disp=FAIL_IF_EXISTS
) throw(Assertion,SemaphoreException);
virtual ~SemaphoreGroup( void );
//
// Operator overloads
//
bool operator==( SemaphoreGroupCref ) const;
//
// Accessors
//
Short getSemaphoreCount( void ) const;
inline SemaphoreGroupIdentifierCref getIdentifier( void ) const
{
return theIdentifier;
}
//
// Factory methods
//
virtual AbstractSemaphorePtr createSemaphore( void )
throw( SemaphoreException ) = 0;
virtual AbstractSemaphorePtr createSemaphore
(
SemaphoreIdentifierRef aIdentifier,
CreateDisposition disp = CREATE_OR_REUSE,
bool Recursive=false,
bool Balking = false
) throw( SemaphoreException ) = 0;
virtual AbstractSemaphorePtr createSemaphore
(
std::string aName,
CreateDisposition disp = CREATE_OR_REUSE,
bool Recursive=false,
bool Balking = false
) throw( SemaphoreException ) = 0;
virtual void destroySemaphore( AbstractSemaphorePtr )
throw( SemaphoreException ) = 0;
protected:
//
// Constructors
//
SemaphoreGroup( void ) throw( Assertion );
SemaphoreGroup( SemaphoreGroupCref )
throw( Assertion );
//
// Operator overloads
//
SemaphoreGroupRef operator=( SemaphoreGroupCref )
throw( Assertion );
//
// Methods for shared control
//
void setGroupType( IntCref ) const;
//
// Methods for SemaphoreGroup base
//
inline bool isPrivate( void ) const
{
return (theGroupCSA == NULLPTR);
}
protected:
private:
friend class SemaphoreCommon;
SemaphoreGroupIdentifier theIdentifier;
Short theNumberOfSemaphores;
CSAGrpHeaderPtr theGroupCSA;
Char theName[NAMEBUFFERSIZE];
};
}
#endif // if !defined(__SEMAPHOREGROUP_HPP)
/*
Common rcs information do not modify
$Author: prudhomm $
$Revision: 1.9 $
$Date: 2000/08/31 22:52:20 $
$Locker: $
*/
corelinux::SemaphoreGroup::getIdentifier
SemaphoreGroupIdentifierCref getIdentifier(void) const
Return the SemaphoreGroupIdentifier.
Definition: SemaphoreGroup.hpp:171
corelinux::SemaphoreReference
Definition: SemaphoreGroup.hpp:45
corelinux
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
corelinux::CreateDisposition
CreateDisposition
Creation dispositions for various system utilities.
Definition: AccessRights.hpp:63
corelinux::SemaphoreCommon
The SemaphoreCommon manages the SemaphoreGroup common storage area.
Definition: SemaphoreCommon.hpp:89
corelinux::FAIL_IF_EXISTS
Will throw exception if target exists.
Definition: AccessRights.hpp:71
corelinux::ScalarIdentifier
ScalarIdentifier provides a templated interface for declaring CoreLinux Identifiers for simple scalar...
Definition: ScalarIdentifiers.hpp:37
corelinux::_CSAGroupHeader
Describes a CSA semaphore group.
Definition: SemaphoreCommon.hpp:48
corelinux::AbstractSemaphore
A AbstractSemaphore supports the protocol that processes and/or threads agree to follow for the purpo...
Definition: AbstractSemaphore.hpp:85
corelinux::OWNER_ALL
Owner has read/write access.
Definition: AccessRights.hpp:43
corelinux::SemaphoreException
SemaphoreException is the base exception type for Semaphore.
Definition: SemaphoreException.hpp:39
corelinux::Assertion
Assertion is-a Exception created when an assertion fails.
Definition: Assertion.hpp:423
corelinux::Synchronized
Synchronized is a mixin which allows class objects to enable monitor functionality.
Definition: Synchronized.hpp:41
corelinux::CREATE_OR_REUSE
Will create or open.
Definition: AccessRights.hpp:67
corelinux::SemaphoreGroup::isPrivate
bool isPrivate(void) const
Claim an unused semaphore from the group.
Definition: SemaphoreGroup.hpp:299
corelinux::SemaphoreGroup
A SemaphoreGroup is an extension to the Linux semaphore set.
Definition: SemaphoreGroup.hpp:62

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