93 static constexpr
int kInfinite{-1};
138 bool acquire(
size_t n = 1,
int timeout_ms = kInfinite);
169 std::unique_ptr<Impl> impl_;
Counting semaphore that can be shared across processes through an OS name.
Definition: sys_semaphore.h:88
bool detach(bool force=true)
Releases the kernel handle and optionally unlinks the named object.
bool is_attached() const
Reports whether the wrapper currently owns a kernel handle.
~SysSemaphore()
Destructor. Invokes detach(false) when the wrapper is still attached.
bool attach(const std::string &name)
Creates or opens the kernel object identified by name.
bool acquire(size_t n=1, int timeout_ms=kInfinite)
Decrements the kernel counter by n, blocking when permits are unavailable.
SysSemaphore(size_t count=0)
Constructs the wrapper with the initial count used when attach() creates the kernel object.
size_t get_count() const
Returns a non-atomic snapshot of the current counter value.
void release(size_t n=1)
Increments the kernel counter by n, waking blocked acquirers.
Cross-platform macros for visibility, branch hints, copy prevention, singletons and string helpers.
#define VLINK_EXPORT
Definition: macros.h:81
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
Definition: macros.h:174