Page
Library
Module
Module type
Parameter
Class
Class type
Source
Lwt_pipe
SourceStream processing using:
Examples:
#require "lwt";;
module P = Lwt_pipe;;
let p1 =
P.of_list CCList.(1 -- 100)
|> P.Reader.map ~f:string_of_int;;
Lwt_io.with_file ~mode:Lwt_io.output "/tmp/foo"
(fun oc ->
let p2 = P.IO.write_lines oc in
P.connect ~ownership:`InOwnsOut p1 p2;
P.wait p2
);;
status: experimental
A pipe between producers of values of type 'a, and consumers of values of type 'a.
keep p fut
adds a pointer from p
to fut
so that fut
is not garbage-collected before p
close p
closes p
, which will not accept input anymore. This sends End
to all readers connected to p
Same as close
but does not wait for completion of dependent tasks
Create a new pipe.
val connect :
?ownership:[ `None | `InOwnsOut | `OutOwnsIn ] ->
('a, [> `r ]) t ->
('a, [> `w ]) t ->
unit
connect p1 p2
forwards every item output by p1
into p2
's input until p1
is closed.
link_close p ~after
will close p
when after
closes. if after
is closed already, closes p
immediately
val read_with_timeout :
('a, [> `r ]) t ->
timeout:float option ->
'a read_timeout_result Lwt.t
read_with_timeout p ~timeout
read the next value from a Pipe, optionally waiting for at most a number of seconds passed with the timeout
parameter.
to_stream p
returns a stream with the content from p
. The stream will close when p
closes.
of_stream s
reads from s
. The returned pipe will close when s
closes.
Iterates on the reader. Errors are ignored (but stop the list).