diff --git a/src/picos/nanoev_picos.ml b/src/picos/nanoev_picos.ml index 0835252..414bf38 100644 --- a/src/picos/nanoev_picos.ml +++ b/src/picos/nanoev_picos.ml @@ -66,13 +66,15 @@ module Global_ = struct Thread.join st.th end -let has_bg_thread = Global_.has_bg_thread -let setup_bg_thread = Global_.setup_bg_thread -let shutdown_bg_thread = Global_.shutdown_bg_thread +module Background_thread = struct + let is_setup = Global_.has_bg_thread + let setup = Global_.setup_bg_thread + let shutdown = Global_.shutdown_bg_thread -let with_setup_bg_thread ev f = - setup_bg_thread ev; - Fun.protect ~finally:shutdown_bg_thread f + let with_setup ev f = + setup ev; + Fun.protect ~finally:shutdown f +end let[@inline] get_loop_exn_ () : Nanoev.t = match Atomic.get Global_.st with diff --git a/src/picos/nanoev_picos.mli b/src/picos/nanoev_picos.mli index a35bb4b..27310dc 100644 --- a/src/picos/nanoev_picos.mli +++ b/src/picos/nanoev_picos.mli @@ -1,17 +1,16 @@ (** Basic interface with picos *) module Background_thread : sig - val setup_bg_thread : Nanoev.t -> unit + val setup : Nanoev.t -> unit (** Install this event loop in a background thread *) - val shutdown_bg_thread : unit -> unit - (** Shutdown background thread, assuming {! has_bg_thread} returns [true] *) + val shutdown : unit -> unit + (** Shutdown background thread, assuming {! is_setup} returns [true] *) - val with_setup_bg_thread : Nanoev.t -> (unit -> 'a) -> 'a + val with_setup : Nanoev.t -> (unit -> 'a) -> 'a - val has_bg_thread : unit -> bool - (** [has_bg_thread ()] is [true] iff a background thread is running a nanoev - loop *) + val is_setup : unit -> bool + (** [is_setup()] is [true] iff a background thread is running a nanoev loop *) end (** {2 Non blocking IO primitives} *)