moonpool/src/core/background_thread.mli
Simon Cruanes 4bf456e1ea
feat: add Background_thread
a version of `Fifo_pool` optimized for a single thread.
2024-02-20 13:43:06 -05:00

26 lines
808 B
OCaml

(** A simple runner with a single background thread.
Because this is guaranteed to have a single worker thread,
tasks scheduled in this runner always run asynchronously but
in a sequential fashion.
This is similar to {!Fifo_pool} with exactly one thread.
@since NEXT_RELEASE
*)
include module type of Runner
type ('a, 'b) create_args =
?on_init_thread:(dom_id:int -> t_id:int -> unit -> unit) ->
?on_exit_thread:(dom_id:int -> t_id:int -> unit -> unit) ->
?on_exn:(exn -> Printexc.raw_backtrace -> unit) ->
?around_task:(t -> 'b) * (t -> 'b -> unit) ->
?name:string ->
'a
(** Arguments used in {!create}. See {!create} for explanations. *)
val create : (unit -> t, _) create_args
(** Create the background runner *)
val with_ : (unit -> (t -> 'a) -> 'a, _) create_args