package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v2.8.tar.gz
md5=03b80e963186e91ddac62ef645bf7fb2
sha512=c8f434808be540c16926bf03d89f394d33fc2d092f963a7b6d412481229e0a96290f1ad7c7d522415115d35426b7aa0b3fda4b991ddc321dad279d402c9a0c0b

doc/containers.thread/CCSemaphore/index.html

Module CCSemaphoreSource

Semaphores

  • since 0.13
Sourcetype t

A semaphore

Sourceval create : int -> t

create n creates a semaphore with initial value n.

Sourceval get : t -> int

Current value.

Sourceval acquire : int -> t -> unit

acquire n s blocks until get s >= n, then atomically sets s := !s - n.

Sourceval release : int -> t -> unit

release n s atomically sets s := !s + n.

Sourceval with_acquire : n:int -> t -> f:(unit -> 'a) -> 'a

with_acquire ~n s ~f first acquires s with n units, calls f (), and then releases s with n units. Safely release the semaphore even if f () fails.

Sourceval wait_until_at_least : n:int -> t -> f:(unit -> 'a) -> 'a

wait_until_at_least ~n s ~f waits until get s >= n, then calls f () and returns its result. Doesn't modify the semaphore.

OCaml

Innovation. Community. Security.

On This Page
  1. Semaphores