Skip to content

Commit 2100893

Browse files
committed
Ensure instantaneous_domain_index
1 parent b507ca2 commit 2100893

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

lib/picos_select/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
backoff
1616
threads.posix
1717
psq
18+
multicore-magic
1819
mtime
1920
mtime.clock.os))
2021

lib/picos_select/picos_select.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ let configure ?(intr_sig = Sys.sigusr2) ?(handle_sigchld = true)
319319
reconfigure_signal_handlers ()
320320

321321
let check_configured () =
322+
(* [instantenous_domain_index] uses [Domain.at_exit] and we want to ensure it
323+
is called as early as possible. *)
324+
Multicore_magic.instantaneous_domain_index () |> ignore;
322325
if config.intr_sigs == [] then configure ()
323326
else reconfigure_signal_handlers ()
324327

lib/picos_select/picos_select.mli

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,22 @@ val configure :
124124
thread on the main domain before any threads or domains besides the main are
125125
created or spawned. *)
126126

127-
val handle_signal : int -> unit
128-
(** [handle_signal signum] should be called to notify this module of a signal
129-
when {{!configure} configured} to not handle said signals. *)
130-
131127
val check_configured : unit -> unit
132128
(** [check_configured ()] checks whether this module has already been
133129
{{!configure} configured} or not and, if not, calls {!configure} with
134130
default arguments. In either case, calling [check_configured ()] will
135-
(re)configure signal handling for the current thread.
131+
(re)configure signal handling for the current thread and perform other
132+
required initialization for the thread to use this module.
133+
134+
⚠️ This should be called at the start of every thread using this module.
136135
137-
ℹ️ The intended use case for [check_configure ()] is at the point of
138-
entry of schedulers and other facilities that use this module. *)
136+
ℹ️ The intended use case for [check_configured ()] is at the point of entry
137+
of schedulers and other facilities that use this module. In other words,
138+
application code should ideally not need to call this directly. *)
139+
140+
val handle_signal : int -> unit
141+
(** [handle_signal signum] should be called to notify this module of a signal
142+
when {{!configure} configured} to not handle said signals. *)
139143

140144
(** {1 Examples}
141145

0 commit comments

Comments
 (0)