Module Tezos_bees.Task_worker

This module provides an easy-to-use generic worker in order to run computations in parallel. It uses a dedicated pool of domains that is shared amongst all components of the same process. Important: the task worker inherits the main event loop switch that is available when it is created. If this switch is terminated, it will result in an inoperative task worker.

type 'a message_error =
  1. | Closed of Tezos_base.TzPervasives.error list option
  2. | Request_error of 'a
  3. | Any of exn
val number_of_domains : int
val launch_task_and_wait : string -> ('a -> 'b) -> ?on_completion:('b -> unit) -> 'a -> ('b, 'c message_error) Stdlib.result Eio.Promise.t

launch_task_and_wait name func ?on_completion arg create a request named name and executing func args, and push it to a worker queue. worker is created at toplevel and shared amongst all the components. Returns a promise for the request result. An optional callback on_completion can be used to trigger specific computations once the request is completed.

val launch_tasks_and_wait : ?max_fibers:int -> string -> ('a -> 'b) -> ?on_completion:('b -> unit) -> 'a list -> ('b, 'c message_error) Stdlib.result list

launch_tasks_and_wait ?max_fibers name func ?on_completion args runs launch_task_and_wait for each each arg in args, in parallel. max_fibers sets the maximum number of fibers to run concurrently (default = max_int).

val launch_task : string -> ('a -> 'b) -> ?on_completion:('b -> unit) -> 'a -> bool

launch_task name func ?on_completion arg create a request named name and executing func args, and push it to worker queue, true if the request has been pushed successfully and false otherwise. An optional callback on_completion can be used to trigger specific computations once the request is completed