mli for worker loop

This commit is contained in:
Simon Cruanes 2025-03-13 10:07:39 -04:00
parent a20208ec37
commit deb96302e1
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

37
src/core/worker_loop_.mli Normal file
View file

@ -0,0 +1,37 @@
(** Internal module that is used for workers.
A thread pool should use this [worker_loop] to run tasks,
handle effects, etc. *)
open Types_
type task_full =
| T_start of {
fiber: fiber;
f: unit -> unit;
}
| T_resume : {
fiber: fiber;
k: unit -> unit;
}
-> task_full
val _dummy_task : task_full
type around_task =
| AT_pair : (Runner.t -> 'a) * (Runner.t -> 'a -> unit) -> around_task
exception No_more_tasks
type 'st ops = {
schedule: 'st -> task_full -> unit;
get_next_task: 'st -> task_full;
get_thread_state: unit -> 'st;
around_task: 'st -> around_task;
on_exn: 'st -> Exn_bt.t -> unit;
runner: 'st -> Runner.t;
before_start: 'st -> unit;
cleanup: 'st -> unit;
}
val worker_loop : block_signals:bool -> ops:'st ops -> 'st -> unit