Sane C++ Libraries
C++ Platform Abstraction Libraries
Async Streams

🟨 Concurrently read and write a byte stream staying inside fixed buffers

Async Streams read and write data concurrently from async sources to destinations.

Note
Even if the state machine is not strictly depending on Async, most practical uses of this library will be using it, so it can be considered an extension of Async

Read and writes happen in parallel if sources and destinations are asynchronous. This library does not allocate any memory, all buffers are supplied by the caller.

Features

Async Streams support reading from an async source and placing such reads in a request queue. This queue is bounded, so it will pause the stream when it becomes full. Data is pushed downstream to listeners of data events. Such listeners can be for example writers and they will eventually emit a drain event that resumes the readable streams that may have been paused.

Async Stream Description
AsyncReadableStream Async source abstraction emitting data events in caller provided byte buffers.
AsyncWritableStream Async destination abstraction where bytes can be written to.
AsyncPipeline Pipes reads on SC::AsyncReadableStream to SC::AsyncWritableStream.

Implementation

Async streams is heavily inspired by Node.js streams but drops a few features to concentrate on the most useful abstraction.

Memory allocation

Async streams do not allocate any memory, but use caller provided buffers for handling data and request queues.

Roadmap

🟩 Usable features:

  • Transform Streams

🟦 Complete Features:

  • Duplex Streams

💡 Unplanned Features:

  • Object Mode
  • readable + read mode