Library
Module
Module type
Parameter
Class
Class type
Stream 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.
type ('a, 'perm) pipe = ('a, 'perm) t
keep p fut
adds a pointer from p
to fut
so that fut
is not garbage-collected before p
val is_closed : (_, _) t -> bool
close p
closes p
, which will not accept input anymore. This sends End
to all readers connected to p
val close_nonblock : (_, _) t -> unit
Same as close
but does not wait for completion of dependent tasks
val create : ?on_close:(unit -> unit) -> ?max_size:int -> unit -> ('a, 'perm) t
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.
val to_stream : ('a, [> `r ]) t -> 'a Lwt_stream.t
to_stream p
returns a stream with the content from p
. The stream will close when p
closes.
val of_stream : 'a Lwt_stream.t -> ('a, [> `r ]) t
of_stream s
reads from s
. The returned pipe will close when s
closes.
module Writer : sig ... end
module Reader : sig ... end
val of_list : 'a list -> 'a Reader.t
val of_array : 'a array -> 'a Reader.t
val of_string : string -> char Reader.t
Iterates on the reader. Errors are ignored (but stop the list).
module IO : sig ... end