00001
#if !defined(__SEMAPHORE_HPP)
00002
#define __SEMAPHORE_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#if !defined(__COMMON_HPP)
00025
#include <Common.hpp>
00026
#endif
00027
00028
#if !defined(__ABSTRACTSEMAPHORE_HPP)
00029
#include <AbstractSemaphore.hpp>
00030
#endif
00031
00032
#if !defined(__SEMAPHOREEXCEPTION_HPP)
00033
#include <SemaphoreException.hpp>
00034
#endif
00035
00036
namespace corelinux
00037 {
00038
00039 DECLARE_CLASS( Semaphore );
00040
00061 class Semaphore :
public AbstractSemaphore
00062 {
00063
00064
public:
00065
00066
00067
00068
00069
00070
00082
Semaphore
00083 (
00084
SemaphoreGroupPtr,
00085
SemaphoreIdentifierRef,
00086
bool Recursive=
false,
00087
bool Balking=
false
00088 )
throw (
NullPointerException );
00089
00091
00092
virtual ~Semaphore(
void );
00093
00094
00095
00096
00097
00099
00100
bool operator==(
SemaphoreCref aRef )
const;
00101
00102
00103
00104
00105
00107
00108
virtual bool isBalkingEnabled(
void )
const;
00109
00111
00112
virtual bool isRecursionEnabled(
void )
const;
00113
00115
00116
virtual ThreadIdentifierCref
getOwningThreadIdentifier(
void )
const;
00117
00119
00120
virtual CounterCref
getRecursionQueueLength(
void )
const;
00121
00122
00123
protected:
00124
00125
00126
00127
00128
00130
00131
Semaphore(
void )
00132
throw(
Assertion);
00133
00135
00136
Semaphore(
SemaphoreCref )
00137
throw(
Assertion);
00138
00139
00140
00141
00143
00144
SemaphoreRef operator=(
SemaphoreCref )
00145
throw(
Assertion);
00146
00148
00149 CounterCref
operator++(
void );
00150
00152
00153 CounterCref
operator--(
void );
00154
00155
00156
00157
00158
00160
00161
virtual ThreadIdentifierRef
getOwnerId(
void );
00162
00163
00164
00165
00166
00168
00169
virtual void setOwnerId(
void );
00170
00172
00173
virtual void setRecursionQueueLength( Counter );
00174
00176
00177
virtual void resetOwnerId(
void );
00178
00179
00180
private:
00181
00183
00184 ThreadIdentifier theOwningThread;
00185
00187
00188 Counter theRecursionQueueLength;
00189
00191
00192
bool theRecursiveMode;
00193
00195
00196
bool theBalkingMode;
00197
00198 };
00199 }
00200
00201
#endif // if !defined(__SEMAPHORE_HPP)
00202
00203
00204
00205
00206
00207
00208
00209
00210