package async_rpc_kernel

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Direct_stream_writer.GroupSource

Group of direct writers. Groups are optimized for sending the same message to multiple clients at once.

Sourcetype 'a t
Sourcemodule Buffer : sig ... end

A group internally holds a buffer to serialize messages only once. This buffer will grow automatically to accomodate bigger messages.

Sourceval create : ?buffer:Buffer.t -> ?send_last_value_on_add:bool -> unit -> _ t
Sourceval flushed_or_closed : _ t -> unit Async_kernel.Deferred.t

flushed_or_closed t is determined when the underlying writer for each member of t is flushed or closed.

Sourceval flushed : _ t -> unit Async_kernel.Deferred.t
  • deprecated [since 2019-11] renamed as [flushed_or_closed]
Sourceval add_exn : 'a t -> 'a t -> unit

Add a direct stream writer to the group. Raises if the writer is closed or already part of the group, or if its bin-prot writer is different than an existing group member's. When the writer is closed, it is automatically removed from the group.

Sourceval remove : 'a t -> 'a t -> unit

Remove a writer from a group. Note that writers are automatically removed from all groups when they are closed, so you only need to call this if you want to remove a writer without closing it.

Sourceval write : 'a t -> 'a -> unit Async_kernel.Deferred.t

Write a message on all direct writers in the group. Contrary to Direct_stream_writer.write, this cannot return `Closed as elements of the group are removed immediately when they are closed.

write t x is the same as write_without_pushback t x; flushed t.

Note: if the group was created with ~send_last_value_on_add:true, all write functions will save the value when written. If there are writers in the group at the time of writing, it will be serialized and saved to the buffer, but if there are no writers it will hold onto the 'a. This means that it is unsafe to use if the 'a is mutable or if it has a finalizer that is expected to be run

Sourceval write_without_pushback : 'a t -> 'a -> unit
Sourceval to_list : 'a t -> 'a t list
Sourceval length : _ t -> int
Sourcemodule Expert : sig ... end

When these functions are used with a group created with ~send_last_value_on_add:true, the group will save a copy of the relevant part of the buffer in order to send it to writers added in the future.