Module IBase.TaskGenerator

type 'child_id for_child_info = {
  1. child_slot : int;
  2. child_id : 'child_id;
  3. is_first_update : bool;
}
type ('work, 'result, 'child_id) t = {
  1. remaining_tasks : unit -> int;
    (*

    number of tasks remaining to complete -- only used for reporting, so imprecision is not a bug

    *)
  2. is_empty : unit -> bool;
    (*

    when should the main loop of the task manager stop expecting new tasks

    *)
  3. finished : result:'result option -> 'work -> unit;
    (*

    Process pool calls finished result:r x when a worker finishes item x. result is None when the item was completed successfully and Some pname when it failed because it could not lock pname. This is only called if next () has previously returned Some x and x was sent to a worker.

    *)
  4. next : 'child_id for_child_info -> 'work option;
    (*

    next () generates the next work item. If is_empty () is true then next () must return None. However, it is OK to for next () to return None when is_empty is false. This corresponds to the case where there is more work to be done, but it is not schedulable until some already scheduled work is finished.

    *)
}

abstraction for generating jobs

val chain : ('work, 'result, 'child_id) t -> ('work, 'result, 'child_id) t -> ('work, 'result, 'child_id) t

chain two generators in order

val of_list : finish:('result option -> 'work -> 'work option) -> 'work list -> ('work, 'result, _) t

schedule tasks out of a concrete list

val finish_always_none : _ option -> _ -> _ option