package containers-thread

  1. Overview
  2. Docs
An extension of containers for threading

Install

Dune Dependency

Authors

Maintainers

Sources

v3.1.tar.gz
md5=18f35ec3794803f5a4f95254f313c764
sha512=090e33705ffb0f77f71f881f78b51d909778bf41afad32339acac21ddbd5f6947b4ebff754148331f9263a544a6000d7f7412d5758e1835fbe84490240b671de

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