Why: Semaphore#
-
class Semaphore#
Public Functions
-
void give()#
Increment the semaphore count (signal/post operation).
This operation is safe to call from interrupt service routines (ISRs).
-
void take()#
Decrement the semaphore count, blocking if necessary.
If the count is greater than zero, decrements it and returns immediately. Otherwise, blocks until another thread calls give().
-
std::expected<void, OSError> take_noblock()#
Attempt to decrement the semaphore count without blocking.
This is the non-blocking version of take(). Safe to call from ISRs.
- Returns:
std::expected<void, OSError> Success if the count was decremented, or an OSError with errno EAGAIN if the count was zero.
-
inline int _pollfd() const#
Get the file descriptor for polling/event loop integration.
- Returns:
int The underlying eventfd file descriptor.
-
void give()#