module Scheduling:sig..end
We need to run several instances of a solver in parallel, with distinct
options. This module provides a clean interface to do that.
type'aor_error =('a, exn) CCResult.t
A MVar is a value that is only accessed atomically
module MVar:sig..end
A future runs in a newly created thread.
module Fut:sig..end
The subprocess is managed in a thread, hidden behind a future.
Cancelling the future will kill the subprocess
typeprocess_status =int
val popen : ?on_res:('a * process_status) or_error
Fut.on_res_callback list ->
string ->
f:(Pervasives.out_channel * Pervasives.in_channel -> 'a) ->
('a * process_status) or_error Fut.tpopen cmd ~f starts a subprocess executing cmd, and calls
f with the (stdin,stdout) of the sub-process, in a new thread.f, process' result status)type shortcut =
| |
Shortcut |
| |
No_shortcut |
module Task:sig..end
type 'a run_result =
| |
Res_one of |
| |
Res_list of |
| |
Res_fail of |
val run : j:int ->
deadline:float -> 'res Task.t list -> 'res run_resultrun ~j tasks runs the given list of tasks in at most j simultaneous
threads, possibly exiting early if a task returns Return_shortcut.
For a task t:
t returns Return x, then x will be in the list of results
iff every other process also returns Return y for some yt returns Return_shortcut x, then still running processes
are killed and Return_shortcut x is returned by the functiont returns Fail e, then still running processes are killed
and Fail e is returned
If some task t raises an exception e,
the whole functions returns Fail e.