1Semaphore.Counting(3)            OCaml library           Semaphore.Counting(3)
2
3
4

NAME

6       Semaphore.Counting - no description
7

Module

9       Module   Semaphore.Counting
10

Documentation

12       Module Counting
13        : sig end
14
15
16
17
18
19
20
21       type t
22
23
24       The type of counting semaphores.
25
26
27
28       val make : int -> t
29
30
31       make  n  returns  a new counting semaphore, with initial value n .  The
32       initial value n must be nonnegative.
33
34
35       Raises Invalid_argument if n < 0
36
37
38
39
40       val release : t -> unit
41
42
43       release s increments the value of semaphore s .  If other  threads  are
44       waiting  on s , one of them is restarted.  If the current value of s is
45       equal to max_int , the value  of  the  semaphore  is  unchanged  and  a
46       Sys_error exception is raised to signal overflow.
47
48
49       Raises Sys_error if the value of the semaphore would overflow max_int
50
51
52
53
54       val acquire : t -> unit
55
56
57       acquire  s  blocks the calling thread until the value of semaphore s is
58       not zero, then atomically decrements the value of s and returns.
59
60
61
62       val try_acquire : t -> bool
63
64
65       try_acquire s immediately returns false if the value of semaphore s  is
66       zero.   Otherwise, the value of s is atomically decremented and try_ac‐
67       quire s returns true .
68
69
70
71       val get_value : t -> int
72
73
74       get_value s returns the current value of semaphore  s  .   The  current
75       value  can be modified at any time by concurrent Semaphore.Counting.re‐
76       lease and Semaphore.Counting.acquire operations.  Hence, the  get_value
77       operation  is racy, and its result should only be used for debugging or
78       informational messages.
79
80
81
82
83
84OCamldoc                          2022-02-04             Semaphore.Counting(3)
Impressum