Module Scheduling

module Scheduling: sig .. end

Scheduling of sub-processes

We need to run several instances of a solver in parallel, with distinct options. This module provides a clean interface to do that.


type 'a or_error = ('a, exn) CCResult.t 

MVar

A MVar is a value that is only accessed atomically

module MVar: sig .. end

Futures

A future runs in a newly created thread.

module Fut: sig .. end

Invoke sub-process

The subprocess is managed in a thread, hidden behind a future. Cancelling the future will kill the subprocess

type process_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.t
popen cmd ~f starts a subprocess executing cmd, and calls f with the (stdin,stdout) of the sub-process, in a new thread.
Returns a future tuple (result of f, process' result status)

Task


type shortcut = 
| Shortcut
| No_shortcut
module Task: sig .. end
type 'a run_result = 
| Res_one of 'a
| Res_list of 'a list
| Res_fail of exn
val run : j:int ->
deadline:float -> 'res Task.t list -> 'res run_result
run ~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:

If some task t raises an exception e, the whole functions returns Fail e.