-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clocks: add real_clock and mono_clock
1. Makes Time.clock polymorphic 2. Rename clock to real_clock 3. Add mono_clock 4. Change benchmarks to use monotonic clock from realtime clock
- Loading branch information
Showing
22 changed files
with
110 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
(library | ||
(name eio) | ||
(public_name eio) | ||
(flags (:standard -open Eio__core -open Eio__core.Private)) | ||
(libraries eio__core cstruct lwt-dllist fmt bigstringaf optint)) | ||
(name eio) | ||
(public_name eio) | ||
(flags | ||
(:standard -open Eio__core -open Eio__core.Private)) | ||
(libraries eio__core cstruct lwt-dllist fmt bigstringaf optint ptime mtime)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
exception Timeout | ||
|
||
class virtual clock = object | ||
method virtual now : float | ||
method virtual sleep_until : float -> unit | ||
class virtual ['a] clock = object | ||
method virtual now : 'a | ||
method virtual sleep_until : 'a -> unit | ||
method virtual add_seconds : 'a -> float -> 'a | ||
method virtual to_seconds : 'a -> float | ||
end | ||
|
||
let now (t : #clock) = t#now | ||
let now (t: (_ #clock)) = t#now | ||
|
||
let sleep_until (t : #clock) time = t#sleep_until time | ||
let sleep_until (t : (_ #clock)) time = t#sleep_until time | ||
|
||
let sleep t d = sleep_until t (now t +. d) | ||
let sleep t d = sleep_until t (t#add_seconds t#now d) | ||
|
||
let to_seconds t time = t#to_seconds time | ||
let with_timeout t d = Fiber.first (fun () -> sleep t d; Error `Timeout) | ||
let with_timeout_exn t d = Fiber.first (fun () -> sleep t d; raise Timeout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(library | ||
(name eio_unix) | ||
(public_name eio.unix) | ||
(libraries eio unix threads mtime.clock.os)) | ||
(libraries eio unix threads mtime mtime.clock.os ptime ptime.clock.os)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.