Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::AsyncPipeline Struct Reference

Pipes reads on SC::AsyncReadableStream to SC::AsyncWritableStream. More...

#include <AsyncStreams.h>

Public Member Functions

Result pipe (AsyncReadableStream &asyncSource, Span< AsyncWritableStream * > asyncSinks)
 Reports errors by source, transforms or sinks. More...
 
Result pipe (AsyncReadableStream &asyncSource, Span< AsyncTransformStream * > asyncTransforms, Span< AsyncWritableStream * > asyncSinks)
 Inits the pipeline with a source, transforms and some writable sinks. More...
 
Result start ()
 Starts the pipeline. More...
 

Public Attributes

Event< MaxListeners, ResulteventError
 

Static Public Attributes

static constexpr int MaxListeners = 8
 

Detailed Description

Pipes reads on SC::AsyncReadableStream to SC::AsyncWritableStream.

Back-pressure happens when the source provides data at a faster rate than what the sink (writable) is able to process. When this happens, AsyncPipeline will AsyncReadableStream::pause the (source). It will also AsyncReadableStream::resume it when some writable has finished writing, freeing one buffer. Caller needs to set AsyncPipeline::source field and AsyncPipeline::sinks with valid streams.

Note
It's crucial to use the same AsyncBuffersPool for the AsyncReadableStream and all AsyncWritableStream

Member Function Documentation

◆ pipe() [1/2]

Result SC::AsyncPipeline::pipe ( AsyncReadableStream asyncSource,
Span< AsyncTransformStream * >  asyncTransforms,
Span< AsyncWritableStream * >  asyncSinks 
)

Inits the pipeline with a source, transforms and some writable sinks.

◆ pipe() [2/2]

Result SC::AsyncPipeline::pipe ( AsyncReadableStream asyncSource,
Span< AsyncWritableStream * >  asyncSinks 
)

Reports errors by source, transforms or sinks.

Inits the pipeline with a source and some writable sinks

◆ start()

Result SC::AsyncPipeline::start ( )

Starts the pipeline.

Note
Both source and sinks must have been already setup by the caller

The documentation for this struct was generated from the following file: