17 int status = sem_init(&this->m_handle.
m_semaphore, 0, initial_count);
18 FW_ASSERT(status == 0, static_cast<FwAssertArgType>(status));
29 }
while (status != 0 && errno == EINTR);
30 FW_ASSERT(status == 0 || errno != 0, status);
35 struct timespec abstime{};
36 int clock_status = clock_gettime(CLOCK_REALTIME, &abstime);
37 FW_ASSERT(clock_status == 0, static_cast<FwAssertArgType>(clock_status));
40 abstime.tv_nsec +=
static_cast<long>(interval.
getUSeconds()) * 1000L;
42 if (abstime.tv_nsec >= 1000000000L) {
43 abstime.tv_sec += abstime.tv_nsec / 1000000000L;
44 abstime.tv_nsec = abstime.tv_nsec % 1000000000L;
49 status = sem_timedwait(&this->m_handle.
m_semaphore, &abstime);
50 }
while (status != 0 && errno == EINTR);
51 FW_ASSERT(status == 0 || errno != 0, status);
56 int status = sem_trywait(&this->m_handle.
m_semaphore);
57 FW_ASSERT(status == 0 || errno != 0, status);
63 FW_ASSERT(status == 0 || errno != 0, status);
PosixCountingSemaphore::Status tryWait() override
non-blocking attempt to decrement the semaphore
~PosixCountingSemaphore() override
CountingSemaphore::Status posix_status_to_semaphore_status(int posix_status)
PosixCountingSemaphore::Status post() override
post (increment) the semaphore, potentially waking a waiting thread
PosixCountingSemaphore(U32 initial_count)
PosixCountingSemaphore::Status wait() override
wait (decrement) the semaphore, blocking if count is zero
PosixCountingSemaphore::Status waitTimeout(const Fw::TimeInterval &interval) override
wait on the semaphore with a timeout
CountingSemaphoreHandle * getHandle() override
return the underlying semaphore handle (implementation specific)