package xapi-stdext-threads

  1. Overview
  2. Docs
Xapi's standard library extension, Threads

Install

dune-project
 Dependency

Authors

Maintainers

Sources

xapi-stdext-4.20.0.tbz
sha256=ec93bcab02739d32f8ef09c30db57101bba7d58bb9a503a57dbfc9d81644b4e6
sha512=30db713ad51a9b1dc806bbb88aecec19ed22598a3c23da26aa80cbba431ba18b67e7f6e3834f1a848e75bfb9beeee2a171ddf0547f8c08f36c119a804aeaaf68

doc/xapi-stdext-threads/Xapi_stdext_threads/Semaphore/index.html

Module Xapi_stdext_threads.SemaphoreSource

Sourcetype t
Sourceexception Inconsistent_state of string
Sourceval create : int -> t

create n create a semaphore with initial value n (a positive integer). Raise Invalid_argument if n <= 0

Sourceval acquire : t -> int -> unit

acquire k s block until the semaphore value is >= k (a positive integer), then atomically decrement the semaphore value by k. Raise Invalid_argument if k <= 0

Sourceval release : t -> int -> unit

release k s atomically increment the semaphore value by k (a positive integer). Raise Invalid_argument if k <= 0

Sourceval execute_with_weight : t -> int -> (unit -> 'a) -> 'a

execute_with_weight s k f acquire the semaphore with k, then run f (), and finally release the semaphore with the same value k (even in case of failure in the execution of f). Return the value of f () or re-raise the exception if any.

Sourceval execute : t -> (unit -> 'a) -> 'a

execute s f same as {execute_with_weight} s 1 f