mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
refactor: remove dla
This commit is contained in:
parent
f1ff17dbd6
commit
dd60666676
7 changed files with 7 additions and 62 deletions
|
|
@ -76,20 +76,12 @@ let worker_thread_ (self : state) (runner : t) ~on_exn ~around_task : unit =
|
|||
TLS.set k_cur_storage _dummy_ls
|
||||
in
|
||||
|
||||
let main_loop () =
|
||||
let continue = ref true in
|
||||
while !continue do
|
||||
match Bb_queue.pop self.q with
|
||||
| task -> run_task task
|
||||
| exception Bb_queue.Closed -> continue := false
|
||||
done
|
||||
in
|
||||
|
||||
try
|
||||
(* handle domain-local await *)
|
||||
Dla_.using ~prepare_for_await:Suspend_.prepare_for_await
|
||||
~while_running:main_loop
|
||||
with Bb_queue.Closed -> ()
|
||||
|
||||
let default_thread_init_exit_ ~dom_id:_ ~t_id:_ () = ()
|
||||
|
||||
|
|
|
|||
|
|
@ -62,26 +62,9 @@ let with_suspend (WSH { on_suspend; run; resume }) (f : unit -> unit) : unit =
|
|||
|
||||
E.try_with f () { E.effc }
|
||||
|
||||
(* DLA interop *)
|
||||
let prepare_for_await () : Dla_.t =
|
||||
(* current state *)
|
||||
let st : (_ * suspension) option A.t = A.make None in
|
||||
|
||||
let release () : unit =
|
||||
match A.exchange st None with
|
||||
| None -> ()
|
||||
| Some (resume, k) -> resume k @@ Ok ()
|
||||
and await () : unit =
|
||||
suspend { handle = (fun ~run:_ ~resume k -> A.set st (Some (resume, k))) }
|
||||
in
|
||||
|
||||
let t = { Dla_.release; await } in
|
||||
t
|
||||
|
||||
[@@@ocaml.alert "+unstable"]
|
||||
[@@@else_]
|
||||
|
||||
let[@inline] with_suspend (WSH _) f = f ()
|
||||
let[@inline] prepare_for_await () = { Dla_.release = ignore; await = ignore }
|
||||
|
||||
[@@@endif]
|
||||
|
|
|
|||
|
|
@ -84,6 +84,3 @@ val with_suspend : with_suspend_handler -> (unit -> unit) -> unit
|
|||
The suspension should always be passed exactly once to
|
||||
[resume]. [run] should be used to start other tasks.
|
||||
*)
|
||||
|
||||
val prepare_for_await : unit -> Dla_.t
|
||||
(** Our stub for DLA. Unstable. *)
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ let worker_thread_ (self : state) ~(runner : t) (w : worker_state) : unit =
|
|||
in
|
||||
|
||||
(* handle domain-local await *)
|
||||
Dla_.using ~prepare_for_await:Suspend_.prepare_for_await ~while_running:main
|
||||
main ()
|
||||
|
||||
let default_thread_init_exit_ ~dom_id:_ ~t_id:_ () = ()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
(** Interface to Domain-local-await.
|
||||
|
||||
This is used to handle the presence or absence of DLA. *)
|
||||
|
||||
type t = {
|
||||
release: unit -> unit;
|
||||
await: unit -> unit;
|
||||
}
|
||||
|
||||
let using : prepare_for_await:(unit -> t) -> while_running:(unit -> 'a) -> 'a =
|
||||
fun ~prepare_for_await:_ ~while_running -> while_running ()
|
||||
|
||||
let setup_domain () = ()
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
type t = Domain_local_await.t = {
|
||||
release: unit -> unit;
|
||||
await: unit -> unit;
|
||||
}
|
||||
|
||||
let using : prepare_for_await:(unit -> t) -> while_running:(unit -> 'a) -> 'a =
|
||||
Domain_local_await.using
|
||||
|
||||
let setup_domain () = Domain_local_await.per_thread (module Thread)
|
||||
|
|
@ -13,11 +13,6 @@
|
|||
from
|
||||
(thread-local-storage -> thread_local_storage_.stub.ml)
|
||||
(-> thread_local_storage_.real.ml))
|
||||
(select
|
||||
dla_.ml
|
||||
from
|
||||
(domain-local-await -> dla_.real.ml)
|
||||
(-> dla_.dummy.ml))
|
||||
(select
|
||||
tracing_.ml
|
||||
from
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue