package picos_std

  1. Overview
  2. Docs

A counting semaphore.

type t

Represents a counting semaphore.

val make : ?padded:bool -> int -> t

make initial creates a new counting semaphore with the given initial count.

val release : t -> unit

release semaphore increments the count of the semaphore.

  • raises Sys_error

    in case the count would overflow.

val acquire : t -> unit

acquire semaphore waits until the count of the semaphore is greater than 0 and then atomically decrements the count.

val try_acquire : t -> bool

try_acquire semaphore attempts to atomically decrement the count of the semaphore unless the count is already 0.

val get_value : t -> int

get_value semaphore returns the current count of the semaphore. This should only be used for debugging or informational messages.

OCaml

Innovation. Community. Security.