ProcessPool.TaskGenerator
type ('a, 'b) t = {
remaining_tasks : unit -> int;
number of tasks remaining to complete -- only used for reporting, so imprecision is not a bug
*)is_empty : unit -> bool;
when should the main loop of the task manager stop expecting new tasks
*)finished : result:'b option -> 'a -> 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.
next : unit -> 'a 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 of_list : 'a list -> ('a, 'b) t
schedule tasks out of a concrete list