Semaphore.hpp
#if !defined(__SEMAPHORE_HPP)
#define __SEMAPHORE_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(__ABSTRACTSEMAPHORE_HPP)
#include <AbstractSemaphore.hpp>
#endif
#if !defined(__SEMAPHOREEXCEPTION_HPP)
#include <SemaphoreException.hpp>
#endif
namespace corelinux
{
DECLARE_CLASS( Semaphore );
class Semaphore : public AbstractSemaphore
{
public:
//
// Constructors and destructors
//
Semaphore
(
SemaphoreGroupPtr,
SemaphoreIdentifierRef,
bool Recursive=false,
bool Balking=false
) throw ( NullPointerException );
virtual ~Semaphore( void );
//
// Operator overloads
//
bool operator==( SemaphoreCref aRef ) const;
//
// Accessors
//
virtual bool isBalkingEnabled( void ) const;
virtual bool isRecursionEnabled( void ) const;
virtual ThreadIdentifierCref getOwningThreadIdentifier( void ) const;
virtual CounterCref getRecursionQueueLength( void ) const;
protected:
//
// Constructors
//
Semaphore( void )
throw(Assertion);
Semaphore( SemaphoreCref )
throw(Assertion);
//
// Operator overloads
//
SemaphoreRef operator=( SemaphoreCref )
throw(Assertion);
CounterCref operator++( void );
CounterCref operator--( void );
//
// Accessors
//
virtual ThreadIdentifierRef getOwnerId( void );
//
// Mutators
//
virtual void setOwnerId( void );
virtual void setRecursionQueueLength( Counter );
virtual void resetOwnerId( void );
private:
ThreadIdentifier theOwningThread;
Counter theRecursionQueueLength;
bool theRecursiveMode;
bool theBalkingMode;
};
}
#endif // if !defined(__SEMAPHORE_HPP)
/*
Common rcs information do not modify
$Author: frankc $
$Revision: 1.2 $
$Date: 2000/06/02 11:51:52 $
$Locker: $
*/
corelinux::Semaphore::getRecursionQueueLength
virtual CounterCref getRecursionQueueLength(void) const
Return the depth of the recursion for the owner.
Definition: Semaphore.cpp:153
corelinux::Semaphore::operator++
CounterCref operator++(void)
Operator for increasing theRecursionQueueLength.
Definition: Semaphore.cpp:118
corelinux::Semaphore::~Semaphore
virtual ~Semaphore(void)
Virtual Destructor.
Definition: Semaphore.cpp:90
corelinux::Semaphore::getOwnerId
virtual ThreadIdentifierRef getOwnerId(void)
Returns a reference to the owning thread.
Definition: Semaphore.cpp:160
corelinux::Semaphore::setRecursionQueueLength
virtual void setRecursionQueueLength(Counter)
Sets the recursion length.
Definition: Semaphore.cpp:174
corelinux::Semaphore::operator=
SemaphoreRef operator=(SemaphoreCref)
Assignment operator throws assertion.
Definition: Semaphore.cpp:110
corelinux::Semaphore::Semaphore
Semaphore(void)
Default constructor throws assertion.
Definition: Semaphore.cpp:43
corelinux::Semaphore::getOwningThreadIdentifier
virtual ThreadIdentifierCref getOwningThreadIdentifier(void) const
Returns the identifier of who currently owns the semaphore.
Definition: Semaphore.cpp:146
corelinux
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
corelinux::NullPointerException
NullPointerException is the base exception type for NullPointer.
Definition: NullPointerException.hpp:40
corelinux::ScalarIdentifier
ScalarIdentifier provides a templated interface for declaring CoreLinux Identifiers for simple scalar...
Definition: ScalarIdentifiers.hpp:37
corelinux::AbstractSemaphore
A AbstractSemaphore supports the protocol that processes and/or threads agree to follow for the purpo...
Definition: AbstractSemaphore.hpp:85
corelinux::Semaphore::operator==
bool operator==(SemaphoreCref aRef) const
Equality operator returns true if identifiers match.
Definition: Semaphore.cpp:100
corelinux::Semaphore
A Semaphore supports the protocol that processes and/or threads agree to follow for the purpose of co...
Definition: Semaphore.hpp:61
corelinux::Assertion
Assertion is-a Exception created when an assertion fails.
Definition: Assertion.hpp:423
corelinux::Semaphore::operator--
CounterCref operator--(void)
Operator for decreasing theRecursionQueueLength.
Definition: Semaphore.cpp:125
corelinux::Semaphore::resetOwnerId
virtual void resetOwnerId(void)
Sets the owner thread id to not owned.
Definition: Semaphore.cpp:181
corelinux::Semaphore::setOwnerId
virtual void setOwnerId(void)
Sets the owner id to the current thread.
Definition: Semaphore.cpp:167
corelinux::Semaphore::isRecursionEnabled
virtual bool isRecursionEnabled(void) const
Returns true if recursion allowed.
Definition: Semaphore.cpp:139
corelinux::Semaphore::isBalkingEnabled
virtual bool isBalkingEnabled(void) const
Returns true if balking enabled.
Definition: Semaphore.cpp:132
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