From 8f7f2050318a246a81c084f69e5a640e02be1283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Thu, 8 Feb 2018 10:51:01 +0100 Subject: [PATCH] Client refactor: Remove usage of `Lwt_unix` from `Lwt_pipe` --- src/lib_shell/worker.ml | 3 ++- src/lib_stdlib_lwt/lwt_pipe.ml | 3 --- src/lib_stdlib_lwt/lwt_pipe.mli | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib_shell/worker.ml b/src/lib_shell/worker.ml index 3ed893db5..ff661f321 100644 --- a/src/lib_shell/worker.ml +++ b/src/lib_shell/worker.ml @@ -184,7 +184,8 @@ module Make Lwt_pipe.pop message_queue >>= fun m -> return (Some m) | Some timeout -> - Lwt_pipe.pop_with_timeout timeout message_queue >>= fun m -> + Lwt_pipe.pop_with_timeout + (Lwt_unix.sleep timeout) message_queue >>= fun m -> return m in match w.buffer with | Queue_buffer message_queue -> pop_queue message_queue diff --git a/src/lib_stdlib_lwt/lwt_pipe.ml b/src/lib_stdlib_lwt/lwt_pipe.ml index dec1b1c07..cccc91844 100644 --- a/src/lib_stdlib_lwt/lwt_pipe.ml +++ b/src/lib_stdlib_lwt/lwt_pipe.ml @@ -144,9 +144,6 @@ let rec pop_with_timeout timeout q = else Lwt.return_none -let pop_with_timeout timeout q = - pop_with_timeout (Lwt_unix.sleep timeout) q - let rec peek ({ closed ; queue ; _ } as q) = if not (Queue.is_empty queue) then let (_elt_size, elt) = Queue.peek queue in diff --git a/src/lib_stdlib_lwt/lwt_pipe.mli b/src/lib_stdlib_lwt/lwt_pipe.mli index 4a627d703..6b6851053 100644 --- a/src/lib_stdlib_lwt/lwt_pipe.mli +++ b/src/lib_stdlib_lwt/lwt_pipe.mli @@ -29,7 +29,7 @@ val pop : 'a t -> 'a Lwt.t (** [pop q] is a thread that blocks while [q] is empty, then removes and returns the first element in [q]. *) -val pop_with_timeout : float -> 'a t -> 'a option Lwt.t +val pop_with_timeout : unit Lwt.t -> 'a t -> 'a option Lwt.t (** [pop t q] is a thread that blocks while [q] is empty, then removes and returns the first element [v] in [q] and to return [Some v], unless no message could be popped