package MlFront_Thunk

  1. Overview
  2. Docs
Describes and runs reproducible units of work called thunks

Install

dune-project
 Dependency

Authors

Maintainers

Sources

MlFront.tar.gz
md5=561d9b7dfc392fcd7413737ac1f6071a
sha512=ec9b2fe9ac45b8429dda4f155f56f73410d1eb12b879e8f826756f2fc3d8fa00d439a75fbd48be9f6dca6cbf3ca691e2b367cd55d227d9a81f77e95cff6d9346

doc/MlFront_Thunk.ThunkIoDisk/MlFront_Thunk_IoDisk/ThunkIoDisk/Make/argument-1-M/index.html

Parameter Make.M

type 'a t

The type 'a t is the set of (future) promises for values of type 'a.

type 'a resolver

The type 'a t is the type of resolvers for pending promises of a value of type 'a.

type resolved_promise_state

The type resolved_promise_state is the set of states a Resolved promise can be in. The set will be either type 'a in t or a reversed monadic transformation of type 'a which you need to unwrap. In other words, the resolution has no knowledge of the transformations of the monad (nor should it!).

include MlFront_Thunk.BuildConstraints.MONAD with type 'a t := 'a t
include MlFront_Thunk.BuildConstraints.FUNCTOR with type 'a t := 'a t
include MlFront_Thunk.BuildConstraints.APPLICATIVE with type 'a t := 'a t
include MlFront_Thunk.BuildConstraints.FUNCTOR with type 'a t := 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val pure : 'a -> 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val make_promise : unit -> 'a t * 'a resolver

make_promise () is a new promise and resolver. The promise is pending.

val return : 'a -> 'a t

return x is a new promise that is already resolved with value x.

promise_state p is the state of the promise

val resolve : 'a resolver -> 'a -> unit

resolve r x resolves the promise p associated with r with value x, meaning that state p will become Resolved x. Requires: p is pending.

val reject : 'a resolver -> exn -> unit

reject r x rejects the promise p associated with r with exception x, meaning that state p will become Rejected x. Requires: p is pending.

val parallel : 'a t list -> 'a list t

parallel ps is a promise that resolves when all the promises in ps resolve, or rejects when any promise in ps rejects. The order of the resolved values is the same as the order of the promises in ps.

yield () is a promise that resolves after the current batch of promises resolve, or after external I/O is detected, or in a short iota.

The returned advised_throttle_sec value is how many seconds the caller should sleep before yielding again. If the promise implementation has a scheduler that wakes up the yield when external I/O is detected, the return value should be 0.0; no sleep is required. But for the minimal promise implementation or a CPU-only scheduler, the return value will be a small positive number so that the caller does not have high CPU busy-waiting for external I/O.

The returned elapsed_sec value is an estimate of how many seconds have elapsed during the yield.