rbufd

Create a ring buffer to manage the data from the given source, and wrap into an iopipe.

The iopipe RingBuffer type uses virtual memory mapping to have the same segment of data mapped to consecutive addresses. This allows true zero-copy usage. However, it does require use of resources that may possibly be limited, so you may want to justify that it's needed before using instead of bufd.

Note also that a RingBuffer is not copyable (its destructor will unmap the memory), so this must use RefCounted to properly work.

  1. auto rbufd(Source dev)
    rbufd
    (
    T = ubyte
    size_t optimalReadSize = 8 * 1024 / T.sizeof
    Source
    )
    (
    Source dev
    )
    if (
    hasMember!(Source, "read") &&
    is(typeof(dev.read(T[].init)) == size_t)
    )
  2. auto rbufd()

Parameters

Source

The type of the input stream. This must have a function read that can read into the buffer's window.

dev Source

The input stream to use. If not specified, then a NullDev source is assumed.

Return Value

Type: auto

An iopipe that uses a RingBuffer to read data from the given device source.

Meta