3#include "gaia/config/config.h"
7#include "gaia/mt/semaphore.h"
14 std::atomic_int32_t m_cnt;
30 const int32_t prevCount = m_cnt.fetch_add(count, std::memory_order_release);
31 int32_t toRelease = -prevCount;
32 if (count < toRelease)
36 m_sem.release(toRelease);
44 const int32_t oldCount = m_cnt.fetch_sub(1, std::memory_order_acquire);
47 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:43
SemaphoreFast(int32_t count=0)
Creates a semaphore with the requested initial system-semaphore count.
Definition semaphore_fast.h:24
void release(int32_t count=1)
Increments semaphore count by the specified amount.
Definition semaphore_fast.h:29
Portable counting semaphore with indefinite waits.
Definition semaphore.h:19