Client refactor: Remove usage of Lwt_unix from Lwt_pipe

This commit is contained in:
Grégoire Henry 2018-02-08 10:51:01 +01:00
parent 7a3277e625
commit 8f7f205031
3 changed files with 3 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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