StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::Buffer::Pipeline Class Referencefinal

A class designed to execute a sequence of functions asynchronously in a pipeline. More...

#include <pipeline.hxx>

Public Member Functions

 Pipeline () noexcept=default
 Default constructor Initializes an empty pipeline buffer.
 
 Pipeline (const Pipeline &other)=default
 Copy constructor Creates a new Pipeline that shares the same underlying buffer as the original.
 
 Pipeline (Pipeline &&other) noexcept=default
 Move constructor Moves the contents of another Pipeline into this instance.
 
 ~Pipeline () noexcept=default
 Destructor.
 
Pipelineoperator= (const Pipeline &other)=default
 Copy assignment operator.
 
Pipelineoperator= (Pipeline &&other) noexcept=default
 Move assignment operator.
 
void AddPipe (const PipeFunction &pipe)
 Adds a new pipe function to the pipeline.
 
void AddPipe (PipeFunction &&pipe)
 Moves a new pipe function to the pipeline.
 
Consumer Process (Consumer buffer) const noexcept
 Processes the pipeline buffer.
 

Detailed Description

A class designed to execute a sequence of functions asynchronously in a pipeline.

The Pipeline class allows users to define a chain of processing functions, where each function:

Functions are executed in the order they are added to the pipeline. Each function runs asynchronously in a detached thread, allowing all functions in the chain to execute concurrently. The output of one function is fed as the input to the next function in the chain. If any function in the chain returns false, the output buffer is marked with a status of Status::Error. It is the responsibility of each subsequent function in the chain to check the input buffer's status and return false if the status is Status::Error. This ensures that the error condition is propagated consistently until the end of the pipeline.

Buffer Status Handling:

Thread Synchronization:

Important Notes:

Constructor & Destructor Documentation

◆ Pipeline() [1/2]

StormByte::Buffer::Pipeline::Pipeline ( const Pipeline other)
default

Copy constructor Creates a new Pipeline that shares the same underlying buffer as the original.

Parameters
otherPipeline to copy

◆ Pipeline() [2/2]

StormByte::Buffer::Pipeline::Pipeline ( Pipeline &&  other)
defaultnoexcept

Move constructor Moves the contents of another Pipeline into this instance.

Parameters
otherPipeline to move

Member Function Documentation

◆ AddPipe() [1/2]

void StormByte::Buffer::Pipeline::AddPipe ( const PipeFunction &  pipe)

Adds a new pipe function to the pipeline.

Parameters
pipePipe function to add

◆ AddPipe() [2/2]

void StormByte::Buffer::Pipeline::AddPipe ( PipeFunction &&  pipe)

Moves a new pipe function to the pipeline.

Parameters
pipePipe function to move

◆ operator=() [1/2]

Pipeline & StormByte::Buffer::Pipeline::operator= ( const Pipeline other)
default

Copy assignment operator.

Parameters
otherPipeline instance to copy from
Returns
Reference to the updated Pipeline instance

◆ operator=() [2/2]

Pipeline & StormByte::Buffer::Pipeline::operator= ( Pipeline &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherPipeline instance to move from
Returns
Reference to the updated Pipeline instance

◆ Process()

Consumer StormByte::Buffer::Pipeline::Process ( Consumer  buffer) const
noexcept

Processes the pipeline buffer.

The provided buffer is passed through the chain of functions in the pipeline. Each function processes the buffer and passes its output to the next function in the chain. All functions are executed asynchronously in detached threads, allowing concurrent processing of the pipeline stages.

The returned buffer represents the final output of the pipeline. Its status indicates the state of the processing:

  • Status::Ready: Data is still being processed in at least one thread.
  • Status::EoF: All threads have completed successfully.
  • Status::Error: An error occurred in one of the threads, and processing was terminated.

Execution Details:

  • Each function in the pipeline runs in a detached thread, and the Async buffer ensures proper synchronization and lifetime management.
  • The pipeline automatically propagates errors by marking the buffer with Status::Error if a function fails.
  • The returned buffer is the last buffer in the chain, ensuring that its status reflects the state of the entire pipeline.
Parameters
bufferBuffer to process
Returns
Processed buffer

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