diff --git a/lib_eio/time.mli b/lib_eio/time.mli index 5143ad2d0..ed999ec2d 100644 --- a/lib_eio/time.mli +++ b/lib_eio/time.mli @@ -57,7 +57,7 @@ module Timeout : sig type t val of_s : #clock -> float -> t - (** [of_s clock duration] is a timeout of [duration] seconds, as measured by [clock]. *) + [@@deprecated "Use [seconds] instead, with a monotonic clock"] val v : #Mono.t -> Mtime.Span.t -> t (** [v clock duration] is a timeout of [duration], as measured by [clock]. diff --git a/tests/network.md b/tests/network.md index 40a4d68df..b2860026e 100644 --- a/tests/network.md +++ b/tests/network.md @@ -685,8 +685,8 @@ First attempt times out: ```ocaml # Eio_mock.Backend.run @@ fun () -> - let clock = Eio_mock.Clock.make () in - let timeout = Eio.Time.Timeout.of_s clock 10. in + let clock = Eio_mock.Clock.Mono.make () in + let timeout = Eio.Time.Timeout.seconds clock 10. in Eio_mock.Net.on_getaddrinfo net [`Return [addr1; addr2]]; let mock_flow = Eio_mock.Flow.make "flow" in Eio_mock.Net.on_connect net [`Run Fiber.await_cancel; `Return mock_flow]; @@ -698,7 +698,7 @@ First attempt times out: ) ) (fun () -> - Eio_mock.Clock.advance clock + Eio_mock.Clock.Mono.advance clock );; +mock-net: getaddrinfo ~service:http www.example.com +mock-net: connect to tcp:127.0.0.1:80 @@ -715,8 +715,8 @@ Both attempts time out: ```ocaml # Eio_mock.Backend.run @@ fun () -> - let clock = Eio_mock.Clock.make () in - let timeout = Eio.Time.Timeout.of_s clock 10. in + let clock = Eio_mock.Clock.Mono.make () in + let timeout = Eio.Time.Timeout.seconds clock 10. in Eio_mock.Net.on_getaddrinfo net [`Return [addr1; addr2]]; Eio_mock.Net.on_connect net [`Run Fiber.await_cancel; `Run Fiber.await_cancel]; Fiber.both @@ -726,10 +726,10 @@ Both attempts time out: ) ) (fun () -> - Eio_mock.Clock.advance clock; + Eio_mock.Clock.Mono.advance clock; Fiber.yield (); Fiber.yield (); - Eio_mock.Clock.advance clock + Eio_mock.Clock.Mono.advance clock );; +mock-net: getaddrinfo ~service:http www.example.com +mock-net: connect to tcp:127.0.0.1:80 diff --git a/tests/time.md b/tests/time.md index af160f046..0986d7525 100644 --- a/tests/time.md +++ b/tests/time.md @@ -113,17 +113,19 @@ let rec loop () = ### Timeouts ```ocaml -# run @@ fun ~clock -> +# Eio_main.run @@ fun env -> + let clock = Eio.Stdenv.mono_clock env in Eio.Time.Timeout.(run_exn none) (fun () -> ()); - let t = Eio.Time.Timeout.of_s clock 0.0001 in + let t = Eio.Time.Timeout.seconds clock 0.0001 in Eio.Time.Timeout.run_exn t (fun () -> Fiber.await_cancel ());; Exception: Eio__Time.Timeout. ``` ```ocaml -# run @@ fun ~clock -> +# Eio_main.run @@ fun env -> + let clock = Eio.Stdenv.mono_clock env in let show d = - let t = Eio.Time.Timeout.of_s clock d in + let t = Eio.Time.Timeout.seconds clock d in traceln "%g -> %a" d Eio.Time.Timeout.pp t in show 0.000000001;