Module Sequencer_table.Make
Parameters
Signature
type ('state, 'job_tag) tEvery
Key.tin the table has an associatedstate, which each job running on that key gets access to. Jobs maybe have an associatedjob_tagwhich is provided purely to assist debugging, as the tag is included in the sexp serialization oft.
val sexp_of_t : ('state -> Ppx_sexp_conv_lib.Sexp.t) -> ('job_tag -> Ppx_sexp_conv_lib.Sexp.t) -> ('state, 'job_tag) t -> Ppx_sexp_conv_lib.Sexp.t
val create : unit -> (_, _) tval enqueue : ('state, 'job_tag) t -> key:Key.t -> ?tag:'job_tag -> ('state option -> 'b Async.Deferred.t) -> 'b Async.Deferred.tenqueue t ~key fenqueuesfforkey.fwill be called with the state ofkeywhen invoked.Invariant 1: it is guaranteed that
fwill not be called immediately.Invariant 2: if
fraises, then the exception will be raised to the monitor in effect whenenqueuewas called. Subsequent jobs forkeywill proceed.Invariant 3: to avoid race, there are no deferred operations between finding the state and calling
fwith the state found. Otherwise, the user would need to consider the race that the state passed tofmight have been changed byset_state.
val set_state : ('state, _) t -> key:Key.t -> 'state option -> unitset_state t key state_optsets the state forkeyimmediately. The state will be kept internally until set toNone
val find_state : ('state, _) t -> Key.t -> 'state optionval num_unfinished_jobs : (_, _) t -> Key.t -> intnum_unfinished_jobs t keyreturns the number of jobs forkeyincluding including pending and running.
val mem : (_, _) t -> Key.t -> boolmem t keyreturnstrueif there is state or an pending/running job
val fold : ('state, _) t -> init:'b -> f:('b -> key:Key.t -> 'state option -> 'b) -> 'bFold over keys with states or pending/running jobs. It's safe to mutate (
enqueueorset_state) when folding
val prior_jobs_done : (_, _) t -> unit Async.Deferred.tThe result is determined when all jobs enqueued before this are finished. The implementation adds a new job to every key currently with at least one running job attached, so it will affect
num_unfinished_jobs