feat: optional dep on trace

This commit is contained in:
Simon Cruanes 2025-02-14 21:52:57 -05:00
parent a63c26223e
commit ce7ed336c2
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
7 changed files with 24 additions and 3 deletions

View file

@ -20,6 +20,7 @@
(synopsis "Tiny event loop around `select`")
(depends ocaml dune base-unix)
(depopts
(trace (>= 0.7))
(picos
(and (>= 0.5) (< 0.7))))
(tags

View file

@ -14,6 +14,7 @@ depends: [
"odoc" {with-doc}
]
depopts: [
"trace" {>= "0.7"}
"picos" {>= "0.5" & < "0.7"}
]
build: [

View file

@ -2,4 +2,9 @@
(name nanoev)
(public_name nanoev)
(synopsis "Nano ev loop")
(libraries unix))
(libraries unix
(select
trace_.ml
from
(trace.core -> trace_.real.ml)
(-> trace_.dummy.ml))))

View file

@ -1,3 +1,5 @@
module Trace_ = Trace_
module Impl = struct
type 'st ops = {
clear: 'st -> unit;
@ -40,5 +42,3 @@ let rec read (self:t) fd buf i len : int =
| exception Unix.Unix_error (Unix, _, _) ->
read self fd buf i len
*)

View file

@ -28,3 +28,9 @@ val step : t -> unit
val on_readable : t -> Unix.file_descr -> 'a -> 'b -> ('a -> 'b -> unit) -> unit
val on_writable : t -> Unix.file_descr -> 'a -> 'b -> ('a -> 'b -> unit) -> unit
val run_after_s : t -> float -> 'a -> 'b -> ('a -> 'b -> unit) -> unit
(**/**)
module Trace_ = Trace_
(**/**)

3
src/core/trace_.dummy.ml Normal file
View file

@ -0,0 +1,3 @@
let[@inline] with_span ?data:_ ~__FILE__:_ ~__LINE__:_ _name f = f 0L
let[@inline] message ?data:_ _ = ()
let set_thread_name (_ : string) = ()

5
src/core/trace_.real.ml Normal file
View file

@ -0,0 +1,5 @@
let[@inline] with_span ?data ~__FILE__ ~__LINE__ name f =
Trace_core.with_span ?data ~__FILE__ ~__LINE__ name f
let[@inline] message ?data m = Trace_core.message ?data m
let set_thread_name name = Trace_core.set_thread_name name