type 'a next = Job of 'a * (unit -> unit) | Complete | Not_ready
-let run next_job retire_job string_of_job =
+let run next_job retire_job fail_job string_of_job =
(* Number of running threads <= Cmdline.nr_jobs. *)
let running = ref 0 in
Mutex.lock lock;
(match exn with
| None -> retire_job job
- | Some exn -> last_exn := exn :: !last_exn
+ | Some exn ->
+ last_exn := exn :: !last_exn;
+ fail_job job
);
decr running;
Condition.signal cond;
in
let rec loop () =
- if !last_exn = [] then (
+ let continue = !last_exn = [] || Cmdline.keep_going () in
+ if continue then (
match next_job () with
| Complete -> ()
| Not_ready ->