File: clock.mli

package info (click to toggle)
ocaml-eio 1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,548 kB
  • sloc: ml: 14,608; ansic: 1,237; makefile: 25
file content (31 lines) | stat: -rw-r--r-- 917 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(** Note that {!Backend.run_full} provides mock clocks
    that advance automatically when there is nothing left to do. *)

open Eio.Std

type 'time ty = [`Mock | 'time Eio.Time.clock_ty]

module type S = sig
  type time

  type t = time ty r

  val make : unit -> t
  (** [make ()] is a new clock.

      The time is initially set to 0.0 and doesn't change except when you call {!advance} or {!set_time}. *)

  val advance : t -> unit
  (** [advance t] sets the time to the next scheduled event (adding any due fibers to the run queue).
      @raise Invalid_argument if nothing is scheduled. *)

  val try_advance : t -> bool
  (** Like {!advance}, but returns [false] instead of raising an exception. *)

  val set_time : t -> time -> unit
  (** [set_time t time] sets the time to [time] (adding any due fibers to the run queue). *)
end

include S with type time := float

module Mono : S with type time := Mtime.t