mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-12 22:10:46 -05:00
we always keep a thread alive on the main domain as a worker for new tasks, but other domains can still come and go to manage resources properly in case a pool is started and used only for a short while.
27 lines
588 B
OCaml
27 lines
588 B
OCaml
[@@@ifge 5.0]
|
|
[@@@ocaml.alert "-unstable"]
|
|
|
|
let recommended_number () = Domain.recommended_domain_count ()
|
|
|
|
type t = unit Domain.t
|
|
|
|
let get_id (self : t) : int = (Domain.get_id self :> int)
|
|
let spawn : _ -> t = Domain.spawn
|
|
let relax = Domain.cpu_relax
|
|
let join = Domain.join
|
|
let is_main_domain = Domain.is_main_domain
|
|
|
|
[@@@ocaml.alert "+unstable"]
|
|
[@@@else_]
|
|
|
|
let recommended_number () = 1
|
|
|
|
type t = Thread.t
|
|
|
|
let get_id (self : t) : int = Thread.id self
|
|
let spawn f : t = Thread.create f ()
|
|
let relax () = Thread.yield ()
|
|
let join = Thread.join
|
|
let is_main_domain () = true
|
|
|
|
[@@@endif]
|