Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::AsyncPipeline Struct Reference

Pipes read data from SC::AsyncReadableStream, forwarding them to SC::AsyncWritableStream. More...

#include <AsyncStreams.h>

Public Member Functions

 AsyncPipeline (const AsyncPipeline &)=delete
 
 AsyncPipeline (AsyncPipeline &&)=delete
 
AsyncPipelineoperator= (const AsyncPipeline &)=delete
 
AsyncPipelineoperator= (AsyncPipeline &&)=delete
 
Result pipe ()
 Reports errors by source, transforms or sinks.
 
bool unpipe ()
 Unregisters all events from source, transforms and sinks.
 
Result start ()
 Starts the pipeline.
 

Public Attributes

AsyncReadableStreamsource = nullptr
 
AsyncDuplexStreamtransforms [MaxTransforms] = {nullptr}
 Provided source (must be != nullptr)
 
AsyncWritableStreamsinks [MaxSinks] = {nullptr}
 Provided transforms (optional, can be all nullptrs)
 
Event< MaxListeners, ResulteventError = {}
 Provided sinks (at least one must be != nullptr)
 

Static Public Attributes

static constexpr int MaxListeners = 8
 
static constexpr int MaxTransforms = 8
 
static constexpr int MaxSinks = 8
 

Detailed Description

Pipes read data from SC::AsyncReadableStream, forwarding them to SC::AsyncWritableStream.

When the source provides data at a faster rate than what the sink (writable) is able to process, or when running out of buffers to read data into, AsyncPipeline will AsyncReadableStream::pause the source. This is called "back-pressure" handling in the Async Streams terminology. When a writable has finished writing, AsyncReadableStream::resume will be called to try un-pausing. 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()

Result SC::AsyncPipeline::pipe ( )

Reports errors by source, transforms or sinks.

Pipes source, transforms and sinks together

Note
Caller must have already setup source and sinks (and optionally transforms)

◆ start()

Result SC::AsyncPipeline::start ( )

Starts the pipeline.

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

◆ unpipe()

bool SC::AsyncPipeline::unpipe ( )
nodiscard

Unregisters all events from source, transforms and sinks.

Member Data Documentation

◆ eventError

Event<MaxListeners, Result> SC::AsyncPipeline::eventError = {}

Provided sinks (at least one must be != nullptr)

◆ sinks

AsyncWritableStream* SC::AsyncPipeline::sinks[MaxSinks] = {nullptr}

Provided transforms (optional, can be all nullptrs)

◆ transforms

AsyncDuplexStream* SC::AsyncPipeline::transforms[MaxTransforms] = {nullptr}

Provided source (must be != nullptr)


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