package fiber
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=f1d5ac04b7a027f3d549e25cf885ebf7acc135e0291c18e6b43123a799c143ce
sha512=64714ab6155cd04bc33d693fc7a6d9d61aa7a278357eeff159df324e083914fcd556459a3945acacf1bbc3775f2232ab0c78006ab8a434dc58dcf95ffdffac52
doc/fiber/Fiber/Svar/index.html
Module Fiber.Svar
Source
State variables
A "state variable" Svar.t
differs from Ivar.t
in that it can be updated multiple times. It is particularly useful if you'd like to observe the state of a process by subscribing to "interesting" (from your perspective) events.
For example, a build system can have a complex state machine, switching between states like "waiting for source file changes", "building", etc., by calling Svar.write
on the corresponding state variable. If you don't care about most of the states but would like to observe all errors, you can use Svar.wait ~until:is_error
to be woken up when an error happens. Other observers may have different preferences, expressed with different until
predicates. You can also use the non-blocking Svar.read
if you'd like to use polling instead.
'a t
is a state variable holding the value of type 'a
wait t ~until
waits until t
's value satisfies the predicate until
. If the current value satisfies it, wait
returns immediately, otherwise, the caller is blocked.