Private.Thread_pool
SourceA pool of systhreads, to avoid the overhead of creating a new thread for each operation.
create ~sleep_q
is a new thread pool.
sleep_q
is used to register a clean-up task to finish idle threads.
run t fn
runs fn ()
and then marks t
as closed, releasing all idle threads.
val submit :
t ->
ctx:Eio.Private.Fiber_context.t ->
enqueue:(('a, Eio.Exn.with_bt) result -> unit) ->
(unit -> 'a) ->
unit
submit t ~ctx ~enqueue fn
starts running fn
in a sys-thread, which uses enqueue
to return the result.
If ctx
is already cancelled then the error is passed to enqueue
immediately. Systhreads do not respond to cancellation once running.