package devkit

  1. Overview
  2. Docs

Forked workers


module T : WorkerT


type task = T.task
type result = T.result
type t
val create : (task -> result) -> int -> t

create f n starts n parallel workers waiting for tasks

val perform : t -> ?autoexit:bool -> task Enum.t -> (result -> unit) -> unit

perform workers tasks f distributes tasks to all workers in parallel, collecting results with f and returns when all tasks are finished

val stop : ?wait:int -> t -> unit

stop ?wait workers kills worker processes with SIGTERM is wait is specified it will wait for at most wait seconds before killing with SIGKILL, otherwise it will wait indefinitely

  • parameter autoexit

    determines whether workers will exit once there are no more tasks, it means perform shouldn't be called again for this instance