1Semaphore.Binary(3) OCaml library Semaphore.Binary(3)
2
3
4
6 Semaphore.Binary - no description
7
9 Module Semaphore.Binary
10
12 Module Binary
13 : sig end
14
15
16
17
18
19
20
21 type t
22
23
24 The type of binary semaphores.
25
26
27
28 val make : bool -> t
29
30
31 make b returns a new binary semaphore. If b is true , the initial
32 value of the semaphore is 1, meaning "available". If b is false , the
33 initial value of the semaphore is 0, meaning "unavailable".
34
35
36
37 val release : t -> unit
38
39
40 release s sets the value of semaphore s to 1, putting it in the "availā
41 able" state. If other threads are waiting on s , one of them is
42 restarted.
43
44
45
46 val acquire : t -> unit
47
48
49 acquire s blocks the calling thread until the semaphore s has value 1
50 (is available), then atomically sets it to 0 and returns.
51
52
53
54 val try_acquire : t -> bool
55
56
57 try_acquire s immediately returns false if the semaphore s has value 0.
58 If s has value 1, its value is atomically set to 0 and try_acquire s
59 returns true .
60
61
62
63
64
65OCamldoc 2023-01-23 Semaphore.Binary(3)