mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-07 03:35:36 -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
|
TLS.set k_cur_storage _dummy_ls
|
||||||
in
|
in
|
||||||
|
|
||||||
let main_loop () =
|
let continue = ref true in
|
||||||
let continue = ref true in
|
while !continue do
|
||||||
while !continue do
|
match Bb_queue.pop self.q with
|
||||||
match Bb_queue.pop self.q with
|
| task -> run_task task
|
||||||
| task -> run_task task
|
| exception Bb_queue.Closed -> continue := false
|
||||||
| exception Bb_queue.Closed -> continue := false
|
done
|
||||||
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:_ () = ()
|
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 }
|
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"]
|
[@@@ocaml.alert "+unstable"]
|
||||||
[@@@else_]
|
[@@@else_]
|
||||||
|
|
||||||
let[@inline] with_suspend (WSH _) f = f ()
|
let[@inline] with_suspend (WSH _) f = f ()
|
||||||
let[@inline] prepare_for_await () = { Dla_.release = ignore; await = ignore }
|
|
||||||
|
|
||||||
[@@@endif]
|
[@@@endif]
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,3 @@ val with_suspend : with_suspend_handler -> (unit -> unit) -> unit
|
||||||
The suspension should always be passed exactly once to
|
The suspension should always be passed exactly once to
|
||||||
[resume]. [run] should be used to start other tasks.
|
[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
|
in
|
||||||
|
|
||||||
(* handle domain-local await *)
|
(* 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:_ () = ()
|
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
|
from
|
||||||
(thread-local-storage -> thread_local_storage_.stub.ml)
|
(thread-local-storage -> thread_local_storage_.stub.ml)
|
||||||
(-> thread_local_storage_.real.ml))
|
(-> thread_local_storage_.real.ml))
|
||||||
(select
|
|
||||||
dla_.ml
|
|
||||||
from
|
|
||||||
(domain-local-await -> dla_.real.ml)
|
|
||||||
(-> dla_.dummy.ml))
|
|
||||||
(select
|
(select
|
||||||
tracing_.ml
|
tracing_.ml
|
||||||
from
|
from
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue