Skip to content

Commit

Permalink
Time: minor syntactic changes, remove unused min_timeout
Browse files Browse the repository at this point in the history
This minimizes the diff to mirage-xen's time. No change of semantics.
  • Loading branch information
hannesm committed Oct 15, 2020
1 parent d3fa083 commit e1d1e80
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/time.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type sleep = {

module SleepQueue =
Binary_heap.Make (struct
type t = sleep
let compare { time = t1; _ } { time = t2; _ } =
compare t1 t2
end)
type t = sleep
let compare { time = t1; _ } { time = t2; _ } =
compare t1 t2
end)

(* Threads waiting for a timeout to expire: *)
let sleep_queue =
Expand Down Expand Up @@ -103,7 +103,7 @@ let rec restart_threads now =
SleepQueue.remove sleep_queue;
m ();
restart_threads now
| { time = time; thread = thread; _ } when in_the_past now time ->
| { time; thread; _ } when in_the_past now time ->
SleepQueue.remove sleep_queue;
m ();
Lwt.wakeup thread ();
Expand All @@ -114,19 +114,14 @@ let rec restart_threads now =
| Event loop |
+-----------------------------------------------------------------+ *)

let min_timeout a b = match a, b with
| None, b -> b
| a, None -> a
| Some a, Some b -> Some(min a b)

let rec get_next_timeout () =
match SleepQueue.minimum sleep_queue with
| exception Binary_heap.Empty -> None
| { canceled = true; _ } ->
SleepQueue.remove sleep_queue;
m ();
get_next_timeout ()
| { time = time; _ } ->
| { time; _ } ->
Some time

let select_next () =
Expand Down

0 comments on commit e1d1e80

Please sign in to comment.