Stdlib.Condition(3)

πŸ’– NAME πŸ’–

Stdlib.Condition - no description. That's literally it, bestie: no description πŸ˜­πŸ’€


πŸ¦‹ Module πŸ¦‹

Okay so this page is from the OCaml library, and the module is:

Module   Stdlib.Condition

✨ Documentation ✨

The docs are under Module Condition, and it's:

Module Condition
        : (module Stdlib__Condition)

So here's the whole vibe, function by function πŸ‘‡

  • type t β€” the type of condition variables. πŸŽ€
  • val create : unit -> t β€” create() creates and returns a new condition variable. This condition variable should be associated (in the programmer's mind) with a certain mutex m and with a certain property P of the data structure that is protected by the mutex m. ✨
  • val wait : t -> Mutex.t -> unit β€” The call wait c m is permitted only if m is the mutex associated with the condition variable c, and only if m is currently locked. This call atomically unlocks the mutex m and suspends the current thread on the condition variable c. This thread can later be woken up after the condition variable c has been signaled via Condition.signal or Condition.broadcast; however, it can also be woken up for no reason. The mutex m is locked again before wait returns. One cannot assume that the property P associated with the condition variable c holds when wait returns; one must explicitly test whether P holds after calling wait. 😭
The wait caveat is the main-character plot twist: when wait returns, do not assume P holds β€” explicitly test whether P holds after calling wait. 🫢
  • val signal : t -> unit β€” signal c wakes up one of the threads waiting on the condition variable c, if there is one. If there is none, this call has no effect. It is recommended to call signal c inside a critical section, that is, while the mutex m associated with c is locked. πŸ”₯
  • val broadcast : t -> unit β€” broadcast c wakes up all threads waiting on the condition variable c. If there are none, this call has no effect. It is recommended to call broadcast c inside a critical section, that is, while the mutex m associated with c is locked. πŸ‘‘

And that's the whole page, bestie πŸ’… Served up by OCamldoc, dated 2026-06-22, for Stdlib.Condition(3) β€” bye, love u, read ur mutex docs πŸŒˆπŸ’–

πŸ“¦ where this page comes from