11#ifdef JPH_PLATFORM_WINDOWS
13#elif defined(JPH_PLATFORM_LINUX) || defined(JPH_PLATFORM_ANDROID) || defined(JPH_PLATFORM_BSD) || defined(JPH_PLATFORM_WASM)
15 #define JPH_USE_PTHREADS
16#elif defined(JPH_PLATFORM_MACOS) || defined(JPH_PLATFORM_IOS)
17 #include <dispatch/dispatch.h>
18 #define JPH_USE_GRAND_CENTRAL_DISPATCH
19#elif defined(JPH_PLATFORM_BLUE)
23 #include <condition_variable>
45 inline int GetValue()
const {
return mCount.load(std::memory_order_relaxed); }
48#if defined(JPH_PLATFORM_WINDOWS) || defined(JPH_USE_PTHREADS) || defined(JPH_USE_GRAND_CENTRAL_DISPATCH) || defined(JPH_PLATFORM_BLUE)
49#ifdef JPH_PLATFORM_WINDOWS
50 using SemaphoreType =
void *;
51#elif defined(JPH_USE_PTHREADS)
52 using SemaphoreType = sem_t;
53#elif defined(JPH_USE_GRAND_CENTRAL_DISPATCH)
54 using SemaphoreType = dispatch_semaphore_t;
55#elif defined(JPH_PLATFORM_BLUE)
56 using SemaphoreType = JPH_PLATFORM_BLUE_SEMAPHORE;
59 SemaphoreType mSemaphore { };
63 std::condition_variable mWaitVariable;
64 atomic<int> mCount { 0 };
#define JPH_EXPORT
Definition Core.h:275
#define JPH_CACHE_LINE_SIZE
Definition Core.h:545
#define JPH_SUPPRESS_WARNINGS_STD_BEGIN
Definition Core.h:430
#define JPH_SUPPRESS_WARNINGS_STD_END
Definition Core.h:443
unsigned int uint
Definition Core.h:500
#define JPH_NAMESPACE_END
Definition Core.h:425
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
Semaphore()
Constructor.
Definition Semaphore.cpp:26
void Acquire(uint inNumber=1)
Acquire the semaphore inNumber times.
Definition Semaphore.cpp:103
int GetValue() const
Get the current value of the semaphore.
Definition Semaphore.h:45
void Release(uint inNumber=1)
Release the semaphore, signaling the thread waiting on the barrier that there may be work.
Definition Semaphore.cpp:71