This commit is contained in:
Simon Cruanes 2025-11-11 00:01:11 -05:00
parent 8770d4fb9c
commit 2ce3fa7d3e
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -146,7 +146,7 @@ let work_ idx (st : worker_state) : unit =
let () = let () =
assert (Domain_.is_main_domain ()); assert (Domain_.is_main_domain ());
let w = { th_count = Atomic.make 1; q = Bb_queue.create () } in let w = { th_count = Atomic.make 1; q = Bb_queue.create () } in
(* thread that stays alive *) (* thread that stays alive since [th_count>0] will always hold *)
ignore (Thread.create (fun () -> work_ 0 w) () : Thread.t); ignore (Thread.create (fun () -> work_ 0 w) () : Thread.t);
domains_.(0) <- Lock.create (Some w, None) domains_.(0) <- Lock.create (Some w, None)
@ -154,7 +154,8 @@ let[@inline] max_number_of_domains () : int = Array.length domains_
let run_on (i : int) (f : unit -> unit) : unit = let run_on (i : int) (f : unit -> unit) : unit =
assert (i < Array.length domains_); assert (i < Array.length domains_);
let w =
let w : worker_state =
Lock.update_map domains_.(i) (function Lock.update_map domains_.(i) (function
| (Some w, _) as st -> | (Some w, _) as st ->
Atomic.incr w.th_count; Atomic.incr w.th_count;