3#include "gaia/config/config.h"
7#include "gaia/mt/semaphore.h"
14 std::atomic_int32_t m_cnt;
22 explicit SemaphoreFast(int32_t count = 0): m_sem(count), m_cnt(0) {}
27 const int32_t prevCount = m_cnt.fetch_add(count, std::memory_order_release);
28 int32_t toRelease = -prevCount;
29 if (count < toRelease)
33 m_sem.release(toRelease);
40 const int32_t oldCount = m_cnt.fetch_sub(1, std::memory_order_acquire);
43 result = m_sem.wait();
An optimized version of Semaphore that avoids expensive system calls when the counter is greater than...
Definition semaphore_fast.h:12
bool wait()
Decrements semaphore count by 1. If the count is already 0, it waits indefinitely until semaphore cou...
Definition semaphore_fast.h:39
void release(int32_t count=1)
Increments semaphore count by the specified amount.
Definition semaphore_fast.h:26
Definition semaphore.h:18
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9