|
VLink 2.0.0
A high-performance communication middleware
|
In-process counting semaphore with optional timeout. More...
Go to the source code of this file.
Classes | |
| class | vlink::Semaphore |
| In-process counting semaphore with optional acquire timeout. More... | |
Namespaces | |
| namespace | vlink |
In-process counting semaphore with optional timeout.
Semaphore provides classic P/V (acquire/release) semaphore semantics within a single process. It is built on std::mutex and std::condition_variable (via the VLink ConditionVariable, which uses CLOCK_MONOTONIC to avoid NTP clock-jump issues on Linux).
Typical use cases:
acquire() blocks the caller until at least n permits are available.release() is safe to call from any thread, including signal handlers (as long as the underlying std::mutex is signal-safe on the platform).reset() with interrupt_waiters == true is a disruptive operation that wakes all blocked acquire() callers and returns false to them. Use it only during controlled shutdown.SysSemaphore.