The current documentation is as follows:
val get : 'a t -> 'a option Lwt.t
(** [get st] removes and returns the first element of the stream, if
any. *)
val get_available : 'a t -> 'a list
(** [get_available st] returns all available elements of [l] without
blocking. *)
One may think that get_available doesn't remove the elements, but it seems that it actually does (assuming removal is done by consume):
let rec get_available_rec node acc s =
if node == !(s.last) then
let thread = feed s in
match Lwt.state thread with
| Lwt.Return _ ->
get_available_rec node acc s
| Lwt.Fail exn ->
raise exn
| Lwt.Sleep ->
List.rev acc
else
match node.data with
| Some x ->
consume s node;
get_available_rec node.next (x :: acc) s
| None ->
List.rev acc
The current documentation is as follows:
One may think that
get_availabledoesn't remove the elements, but it seems that it actually does (assuming removal is done byconsume):