package shuttle

  1. Overview
  2. Docs

Alternative to Async_unix.Writer, based on the low latency transport in async_rpc.

type t
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val create : ?initial_buffer_size:int -> ?write_timeout:Core.Time_ns.Span.t -> Async_unix.Fd.t -> t

create ?initial_buffer_size ?max_buffer_size ?write_timeout fd creates a new writer.

The writer doesn't flush automatically and the user is responsible for calling flush, which triggers a write system call if needed.

val is_closed : t -> bool
val is_open : t -> bool
val close_started : t -> unit Async_kernel.Deferred.t
val close_finished : t -> unit Async_kernel.Deferred.t
val schedule_bigstring : t -> ?pos:int -> ?len:int -> Core.Bigstring.t -> unit

schedule_bigstring schedules a bigstring to be written on the next flush. It is not safe to modify this bigstring until the writer has been flushed, or closed.

val write_string : t -> ?pos:int -> ?len:int -> string -> unit

write_string copies the string into the writer's internal buffer. The string will surface the next time the writer schedules a write.

val close : t -> unit Async_kernel.Deferred.t

close will close the underlying file descriptor after waiting for the writer to be flushed.

val flush : t -> unit

flush will schedule a write system call if one is needed.

val flushed : t -> unit Async_kernel.Deferred.t

flushed t f deferred that will get resolved when all prior writes have finished.

OCaml

Innovation. Community. Security.