Use a queue to handle tasks in the RestartScheduler

Summary:
The RestartScheduler now uses it's own of_list function to build a
ProcessPool.TaskGenerator to be able to use a queue as the underlying
data structure.

Reviewed By: ngorogiannis

Differential Revision: D19390055

fbshipit-source-id: d57b493b7
master
Fernando Gasperi Jabalera 5 years ago committed by Facebook Github Bot
parent 592c746e6b
commit 4322701ecf

@ -6,13 +6,23 @@
*)
open! IStd
let of_list (lst : 'a list) : 'a ProcessPool.TaskGenerator.t =
let content = Queue.of_list lst in
let length = ref (Queue.length content) in
let remaining_tasks () = !length in
let is_empty () = Queue.is_empty content in
let finished _finished_item = decr length in
let next () = Queue.dequeue content in
{remaining_tasks; is_empty; finished; next}
(** This behaves exactly the same as the FileScheduler so far. The goal is that it will use a work
queue and proc locking to avoid repeating work and hopefully get some in process cache hits. *)
let make sources =
let gen =
List.rev_map sources ~f:(fun sf -> SchedulerTypes.File sf)
|> List.permute ~random_state:(Random.State.make (Array.create ~len:1 0))
|> ProcessPool.TaskGenerator.of_list
|> of_list
in
let next x =
let res = gen.next x in

Loading…
Cancel
Save