7 #ifndef MSynch_InprocessSemaphore_h 8 #define MSynch_InprocessSemaphore_h 14 #include "../../Defines/SmartIncrementor.h" 25 unsigned Int32 iMaximumResourceCount = 0x7fffffff);
36 pthread_cond_t mConditionalVariable;
38 const unsigned Int32 mMaxCount;
40 unsigned Int32 mCount;
41 unsigned Int32 mWaiters;
53 mMaxCount(iMaximumResourceCount),
54 mCount(iInitialAvailableResourceCount),
59 const int lResult = ::pthread_cond_init(&mConditionalVariable,
NULL);
63 throw (
"::pthread_cond_init failed");
70 const int lResult = ::pthread_cond_destroy(&mConditionalVariable);
82 struct timespec lAbsoluteTimeout;
121 if (mCount == mMaxCount)
123 throw (
"MSynch::InprocessSemaphore::ReleaseResource: exceeded the maximum.");
129 const int lResult = ::pthread_cond_signal(&mConditionalVariable);
133 throw (
"::pthread_cond_signal failed");
140 #endif // MSynch_InprocessSemaphore_h bool WaitUntilSpuriouslyWokenUpOrTimeoutExpired(pthread_cond_t &irConditionalVariable, const struct timespec &irAbsoluteTimeout) const
Definition: InprocessRecursiveMutex.h:200
#define _ASSERT(x)
Definition: Asserte.h:34
Definition: InprocessRecursiveMutex.h:25
Definition: ReferenceCountedImpl.h:18
void WaitUntilSpuriouslyWokenUp(pthread_cond_t &irConditionalVariable) const
this method is here only for the ManualEvent
Definition: InprocessRecursiveMutex.h:184
Definition: InprocessRecursiveMutex.h:31
void GetAbsoluteTimeout(struct timespec &oAbsoluteTimeout, unsigned Int32 iMilliseconds)
Definition: AbsoluteTimeout.h:19
#define Int32
Definition: BasicTypes.h:20
InprocessSemaphore(unsigned Int32 iInitialAvailableResourceCount, unsigned Int32 iMaximumResourceCount=0x7fffffff)
Definition: InprocessSemaphore.h:51
bool WaitForResource(unsigned Int32 iMilliseconds)
Definition: InprocessSemaphore.h:75
Definition: SmartIncrementor.h:13
void WaitForeverForResource()
Definition: InprocessSemaphore.h:101
Definition: InprocessSemaphore.h:18
~InprocessSemaphore()
Definition: InprocessSemaphore.h:67
void ReleaseResource()
Definition: InprocessSemaphore.h:116
#define NULL
Definition: Null.h:10