File: prelude.ml

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 (34 lines) | stat: -rw-r--r-- 955 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
32
33
34
#require "eio_main";;
#require "eio.mock";;

module Eio_main = struct
  open Eio.Std

  module Fake_clock = struct
    type time = float
    type t = unit
    let sleep_until () _time = failwith "No sleeping in tests!"
    let now _ = 1623940778.27033591
  end

  let fake_clock =
    let handler = Eio.Time.Pi.clock (module Fake_clock) in
    Eio.Resource.T ((), handler)

  let run fn =
    (* To avoid non-deterministic output, we run the examples a single domain. *)
    let fake_domain_mgr = Eio_mock.Domain_manager.create () in
    Eio_main.run @@ fun env ->
    fn @@ object
      method net         = env#net
      method stdin       = env#stdin
      method stdout      = env#stdout
      method stderr      = env#stderr
      method cwd         = env#cwd
      method process_mgr = env#process_mgr
      method domain_mgr  = fake_domain_mgr
      method clock       = fake_clock
    end
end

let parse_config (flow : _ Eio.Flow.source) = ignore