package b0

  1. Overview
  2. Docs
Software construction and deployment kit

Install

dune-project
 Dependency

Authors

Maintainers

Sources

b0-0.0.6.tbz
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0

doc/b0.std/B0_std/Bval/index.html

Module B0_std.BvalSource

Blocking values.

Note. In direct style the Fut.t values would go away. For now be bundled lazy blocking values in the same structure.

Note. This is an IVar.

Sourcetype 'a setter

The type for setting blocking value.

Sourcetype 'a t

The type for immutable blocking values.

Sourceval make : unit -> 'a t * 'a setter

make () is a blocking value and a setter to set it.

Sourceval of_val : 'a -> 'a t

of_val v is a (non-)blocking value holding v.

Sourceval of_lazy_fun : (unit -> 'a) -> 'a t

of_lazy_fun f is a blocking value that runs f iff get or poll is called on the value.

XXX. Something should be said about the context in which f runs.

Sourceval of_setter : 'a setter -> 'a t

of_setter s is the blocking value of s.

Sourceval is_lazy : 'a t -> bool

is_lazy bv is true iff bv is a lazily triggered value.

Setting

Sourceval set : 'a setter -> 'a -> unit

set s v sets the blocking value of_setter s to value v. Raises Invalid_argument if set is already set.

Sourceval try_set : 'a setter -> 'a -> bool

try_set s v is true if iv was set to v and false if iv was already set.

Sourceval try_set' : 'a setter -> (unit -> 'a) -> bool

try_set' s f is true if iv was set to f () and false if iv was already set, in the latter case f may be or may not have been called.

Getting

Sourceval get : 'a t -> 'a Fut.t

get bv is the value of bv. In direct style, this should be a blocking call.

Sourceval poll : 'a t -> 'a option

poll bv is None if get bv would block and Some _ if it does not block. If bv was created with of_lazy_fun, this ensure the computation gets triggered.

Sourceval stir : 'a t -> unit

stir bv is ignore (poll v). Useful if you know bv will be needed later and may be a of_lazy_fun.

Formatting

Sourceval pp : 'a Fmt.t -> 'a t Fmt.t

pp formats blocking values. Does not block if the value is not set in which case "<pending>" formatted.