2#include "gaia/config/config.h"
3#include "gaia/config/profiler.h"
5#if GAIA_PLATFORM_WINDOWS
6 #define GAIA_USE_MT_STD 1
10 #include <condition_variable>
22 GAIA_PROF_MUTEX(std::mutex, m_mtx);
23 std::condition_variable m_cv;
26 pthread_cond_t m_hCondHandle;
27 pthread_mutex_t m_hMutexHandle;
35 [[maybe_unused]]
int ret = pthread_mutex_init(&m_hMutexHandle,
nullptr);
36 GAIA_ASSERT(ret == 0);
38 ret = pthread_cond_init(&m_hCondHandle,
nullptr);
39 GAIA_ASSERT(ret == 0);
45 [[maybe_unused]]
int ret = pthread_cond_destroy(&m_hCondHandle);
46 GAIA_ASSERT(ret == 0);
48 ret = pthread_mutex_destroy(&m_hMutexHandle);
49 GAIA_ASSERT(ret == 0);
56 auto& mtx = GAIA_PROF_EXTRACT_MUTEX(m_mtx);
57 std::unique_lock lock(mtx);
58 GAIA_PROF_LOCK_MARK(m_mtx);
62 [[maybe_unused]]
int ret = pthread_mutex_lock(&m_hMutexHandle);
63 GAIA_ASSERT(ret == 0);
67 ret = pthread_cond_signal(&m_hCondHandle);
68 GAIA_ASSERT(ret == 0);
70 ret = pthread_mutex_unlock(&m_hMutexHandle);
71 GAIA_ASSERT(ret == 0);
78 auto& mtx = GAIA_PROF_EXTRACT_MUTEX(m_mtx);
79 std::unique_lock lock(mtx);
80 GAIA_PROF_LOCK_MARK(m_mtx);
83 [[maybe_unused]]
int ret = pthread_mutex_lock(&m_hMutexHandle);
84 GAIA_ASSERT(ret == 0);
86 ret = pthread_mutex_unlock(&m_hMutexHandle);
87 GAIA_ASSERT(ret == 0);
95 auto& mtx = GAIA_PROF_EXTRACT_MUTEX(m_mtx);
96 std::unique_lock lock(mtx);
97 GAIA_PROF_LOCK_MARK(m_mtx);
101 [[maybe_unused]]
int ret = pthread_mutex_lock(&m_hMutexHandle);
102 GAIA_ASSERT(ret == 0);
104 ret = pthread_mutex_unlock(&m_hMutexHandle);
105 GAIA_ASSERT(ret == 0);
113 auto& mtx = GAIA_PROF_EXTRACT_MUTEX(m_mtx);
114 std::unique_lock lock(mtx);
115 GAIA_PROF_LOCK_MARK(m_mtx);
116 m_cv.wait(lock, [&] {
120 [[maybe_unused]]
int ret{};
124 ret = pthread_cond_wait(&m_hCondHandle, &m_hMutexHandle);
125 }
while (!ret && !m_set);
127 GAIA_ASSERT(ret != EINVAL);
137 ret = pthread_mutex_lock(&m_hMutexHandle);
138 GAIA_ASSERT(ret == 0);
143 ret = pthread_mutex_unlock(&m_hMutexHandle);
144 GAIA_ASSERT(ret == 0);
Manual-reset style synchronization primitive for waking a waiting thread. The event stays signaled un...
Definition event.h:20
void wait()
Blocks the calling thread until the event becomes signaled.
Definition event.h:111
void set()
Sets the event to the signaled state and wakes one waiting thread.
Definition event.h:54
Event()
Creates an unsignaled event and initializes the underlying pthread objects.
Definition event.h:34
void reset()
Resets the event to the unsignaled state.
Definition event.h:76
GAIA_NODISCARD bool is_set()
Checks whether the event currently is in the signaled state.
Definition event.h:93
~Event()
Destroys the underlying pthread synchronization objects.
Definition event.h:44
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9