20 #include <mach/mach_init.h>
21 #include <mach/mach_traps.h>
22 #include <mach/semaphore.h>
23 #include <mach/task.h>
24 #include <system_error>
30 auto ret = semaphore_create(mach_task_self(), &
m_semaphore, SYNC_POLICY_FIFO, i);
31 if (ret != KERN_SUCCESS) {
41 if (semaphore_signal(
m_semaphore) != KERN_SUCCESS) {
49 if (ret == KERN_SUCCESS) {
52 if (ret == KERN_ABORTED) {
60 const mach_timespec_t
wait{0, 0};
68 auto left = abs_time - now;
73 const mach_timespec_t
wait{
static_cast<unsigned int>(seconds.count()), static_cast<int>(nseconds.count())};
81 auto ret = semaphore_timedwait(m_semaphore, wait);
82 if (ret == KERN_SUCCESS) {
85 if (ret == KERN_OPERATION_TIMED_OUT) {
T duration_cast(T...args)
T system_category(T...args)
bool try_acquire_until(std::chrono::system_clock::time_point abs_time)
bool timed_wait(const mach_timespec_t &wait)
SemaphoreImpl(unsigned int i)