Utils: add Lwt_pipe.pop_all_now
This commit is contained in:
parent
cfd5151279
commit
f145c4b196
@ -162,14 +162,17 @@ let rec values_available q =
|
||||
else
|
||||
Lwt.return_unit
|
||||
|
||||
let pop_all q =
|
||||
let rec loop acc =
|
||||
let rec pop_all_loop q acc =
|
||||
match pop_now_exn q with
|
||||
| exception Empty -> List.rev acc
|
||||
| e -> loop (e :: acc)
|
||||
in
|
||||
| e -> pop_all_loop q (e :: acc)
|
||||
|
||||
let pop_all q =
|
||||
pop q >>= fun e ->
|
||||
Lwt.return (loop [e])
|
||||
Lwt.return (pop_all_loop q [e])
|
||||
|
||||
let pop_all_now q =
|
||||
pop_all_loop q []
|
||||
|
||||
let close q =
|
||||
if not q.closed then begin
|
||||
|
@ -34,6 +34,10 @@ val pop_all : 'a t -> 'a list Lwt.t
|
||||
removes and returns all the element in [q] (in the order they
|
||||
were inserted). *)
|
||||
|
||||
val pop_all_now : 'a t -> 'a list
|
||||
(** [pop_all_now q] returns all the element in [q] (in the order they
|
||||
were inserted), or [[]] if [q] is empty. *)
|
||||
|
||||
val peek : 'a t -> 'a Lwt.t
|
||||
(** [peek] is like [pop] except it does not removes the first
|
||||
element. *)
|
||||
|
Loading…
Reference in New Issue
Block a user