1Stdlib.Condition(3) OCaml library Stdlib.Condition(3)
2
3
4
6 Stdlib.Condition - no description
7
9 Module Stdlib.Condition
10
12 Module Condition
13 : (module Stdlib__Condition)
14
15
16
17
18
19
20
21 type t
22
23
24 The type of condition variables.
25
26
27
28 val create : unit -> t
29
30
31 create() creates and returns a new condition variable. This condition
32 variable should be associated (in the programmer's mind) with a certain
33 mutex m and with a certain property P of the data structure that is
34 protected by the mutex m .
35
36
37
38 val wait : t -> Mutex.t -> unit
39
40 The call wait c m is permitted only if m is the mutex associated with
41 the condition variable c , and only if m is currently locked. This
42 call atomically unlocks the mutex m and suspends the current thread on
43 the condition variable c . This thread can later be woken up after the
44 condition variable c has been signaled via Condition.signal or Condi‐
45 tion.broadcast ; however, it can also be woken up for no reason. The
46 mutex m is locked again before wait returns. One cannot assume that the
47 property P associated with the condition variable c holds when wait re‐
48 turns; one must explicitly test whether P holds after calling wait .
49
50
51
52 val signal : t -> unit
53
54
55 signal c wakes up one of the threads waiting on the condition variable
56 c , if there is one. If there is none, this call has no effect.
57
58 It is recommended to call signal c inside a critical section, that is,
59 while the mutex m associated with c is locked.
60
61
62
63 val broadcast : t -> unit
64
65
66 broadcast c wakes up all threads waiting on the condition variable c .
67 If there are none, this call has no effect.
68
69 It is recommended to call broadcast c inside a critical section, that
70 is, while the mutex m associated with c is locked.
71
72
73
74
75
76OCamldoc 2023-07-20 Stdlib.Condition(3)