44#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
45 using BeforeWaitHook = void (*)(
Semaphore*);
46 static void setBeforeWaitHook(BeforeWaitHook hook);
48 enum MutexTransitionWindow {
52 using MutexTransitionHook = void (*)(MutexTransitionWindow window);
55 static void setMutexTransitionHook(MutexTransitionHook hook);
57 static size_t getHostedTimeoutCreateCount();
58 static size_t getHostedTimeoutDestroyCount();
65 Semaphore(
size_t nInitialValue,
bool canInterrupt =
true);
70 MUST_USE_RESULT bool acquireWithError(
size_t n,
size_t timeoutSecs,
size_t timeoutUsecs,
71 SemaphoreError& error);
82 MUST_USE_RESULT bool acquireForCompletion(
size_t n = 1,
size_t timeoutSecs = 0,
83 size_t timeoutUsecs = 0);
86 bool acquire(
size_t n = 1,
size_t timeoutSecs = 0,
size_t timeoutUsecs = 0);
91 bool tryAcquire(
size_t n = 1);
98 void release(
size_t n = 1);
109 const void* getDebugMutexOwner()
const;
118 void initialiseMutex(
bool locked);
120 bool mutexOwnedByCurrentThread()
const;
126 size_t timeoutUsecs = 0,
127 bool deferTerminal =
false);
142 virtual size_t serialize(uint8_t* pBuffer);
144 virtual size_t getNumber();
151 bool m_bCanInterrupt;