|
|
@ -162,24 +162,21 @@ let process_updates pool buffer =
|
|
|
|
has_dead_child pool
|
|
|
|
has_dead_child pool
|
|
|
|
|> Option.iter ~f:(fun (slot, status) ->
|
|
|
|
|> Option.iter ~f:(fun (slot, status) ->
|
|
|
|
killall pool ~slot (Unix.Exit_or_signal.to_string_hum status) ) ;
|
|
|
|
killall pool ~slot (Unix.Exit_or_signal.to_string_hum status) ) ;
|
|
|
|
match wait_for_updates pool buffer with
|
|
|
|
(* try to schedule more work if there is an idle worker *)
|
|
|
|
| Some (UpdateStatus (slot, t, status)) ->
|
|
|
|
Array.findi pool.pending_items ~f:(fun _idx item -> Option.is_none item)
|
|
|
|
TaskBar.update_status pool.task_bar ~slot t status
|
|
|
|
|> Option.iter ~f:(fun (idle_slot, _) -> send_work_to_child pool idle_slot) ;
|
|
|
|
| Some (Crash slot) ->
|
|
|
|
wait_for_updates pool buffer
|
|
|
|
let {pid} = pool.slots.(slot) in
|
|
|
|
|> Option.iter ~f:(function
|
|
|
|
(* clean crash, give the child process a chance to cleanup *)
|
|
|
|
| UpdateStatus (slot, t, status) ->
|
|
|
|
Unix.wait (`Pid pid) |> ignore ;
|
|
|
|
TaskBar.update_status pool.task_bar ~slot t status
|
|
|
|
killall pool ~slot "see backtrace above"
|
|
|
|
| Crash slot ->
|
|
|
|
| Some (Ready slot) ->
|
|
|
|
let {pid} = pool.slots.(slot) in
|
|
|
|
TaskBar.tasks_done_add pool.task_bar 1 ;
|
|
|
|
(* clean crash, give the child process a chance to cleanup *)
|
|
|
|
send_work_to_child pool slot
|
|
|
|
Unix.wait (`Pid pid) |> ignore ;
|
|
|
|
| None -> (
|
|
|
|
killall pool ~slot "see backtrace above"
|
|
|
|
(* no updates, so try to schedule more work if there is an idle worker *)
|
|
|
|
| Ready slot ->
|
|
|
|
match Array.findi pool.pending_items ~f:(fun _idx item -> Option.is_none item) with
|
|
|
|
TaskBar.tasks_done_add pool.task_bar 1 ;
|
|
|
|
| None ->
|
|
|
|
send_work_to_child pool slot )
|
|
|
|
()
|
|
|
|
|
|
|
|
| Some (idle_slot, _) ->
|
|
|
|
|
|
|
|
send_work_to_child pool idle_slot )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** terminate all worker processes *)
|
|
|
|
(** terminate all worker processes *)
|
|
|
|