StormByte-Buffer 2.0.0
C++26 buffer module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Buffer::Pumper Class Reference

Owns a Bridge and moves bytes until EoF, failure or Cancel. More...

#include <StormByte/buffer/pumper.hxx>

Classes

class  Parameters
 Optional Pumper knobs. More...
 

Public Member Functions

STORMBYTE_FORCE_INLINE Pumper (Bridge &&bridge, Parameters parameters={})
 Take a Bridge and start the worker.
 
 Pumper (const Pumper &)=delete
 
 Pumper (Pumper &&other) noexcept
 Move constructor.
 
 ~Pumper () noexcept
 Destructor.
 
Pumper & operator= (const Pumper &)=delete
 
Pumper & operator= (Pumper &&other) noexcept
 Move assignment.
 
void Cancel () noexcept
 Terminal stop.
 
bool Canceled () const noexcept
 Whether Cancel ran.
 
bool EoF () const noexcept
 Whether the owned Bridge reports EoF.
 
bool Failed () const noexcept
 Whether the owned Bridge failed for real.
 
void Toggle () noexcept
 Pause or resume the worker.
 
const StormByte::Shared< StormByte::Buffer::ReadTelemetry > ReadTelemetry () const noexcept
 Read counters copied from the owned Bridge.
 
const StormByte::Shared< StormByte::Buffer::WriteTelemetry > WriteTelemetry () const noexcept
 Write counters copied from the owned Bridge.
 

Detailed Description

Owns a Bridge and moves bytes until EoF, failure or Cancel.

Starts the worker in the constructor. The destructor joins; it may block until the current cycle finishes. There is no Stop. The destructor does not Cancel: it lets the worker finish. Cancel is terminal (Canceled, no restart). Toggle pauses and resumes. Failed is only a real Bridge fault.

HighWater
Caps how much the worker will pull from the input. nullopt (omitted knob): IO source → 0; non-IO source → backend default (constexpr in the .cxx). Explicit 0: no Pumper cap. Use 0 only when the source is an IO leaf that already limits itself. Non-IO sources are unbounded by design; omitting HighWater is the safe default. 0 on a non-IO source is the caller's choice.
Chunk
Bytes the worker asks Bridge::Passthrough per cycle. 0 is automatic chunking, not Bridge's "current contents". The backend never asks for 0 bytes: a Blocking IO pull of 0 would not touch the origin.
IO pull
If the owned Bridge reports Bridge::InputPullBlocking (stolen reader with IO::BufferedReader::ReadAhead of 0), the worker uses Bridge::Operation::Blocking. Otherwise it uses Bridge::Operation::NonBlocking.
Telemetry
Copies the Bridge handles at construction. Those Shared objects stay valid after Cancel and after *this dies if the caller kept a copy. No extra counters.

An IO path stays locked while this Pumper is alive. After Cancel the owned Bridge is Closed.

Constructor & Destructor Documentation

◆ Pumper() [1/3]

STORMBYTE_FORCE_INLINE StormByte::Buffer::Pumper::Pumper ( Bridge &&  bridge,
Parameters  parameters = {} 
)
inlineexplicit

Take a Bridge and start the worker.

Parameters
bridgeOwned bridge. Moved-from is empty.
parametersOmitted knobs keep the office default.

◆ Pumper() [2/3]

StormByte::Buffer::Pumper::Pumper ( const Pumper &  )
delete

◆ Pumper() [3/3]

StormByte::Buffer::Pumper::Pumper ( Pumper &&  other)
noexcept

Move constructor.

Moved-from is empty and joined.

Parameters
otherInstance to take from.

◆ ~Pumper()

StormByte::Buffer::Pumper::~Pumper ( )
noexcept

Destructor.

Joins the worker. Does not Cancel.

Member Function Documentation

◆ Cancel()

void StormByte::Buffer::Pumper::Cancel ( )
noexcept

Terminal stop.

Sets Canceled. Closes the Bridge.

Idempotent. Does not set Failed. The worker will not resume. Construct a new Pumper to transfer again.

◆ Canceled()

bool StormByte::Buffer::Pumper::Canceled ( ) const
noexcept

Whether Cancel ran.

Returns
Sticky. A canceled Pumper cannot be resumed.

◆ EoF()

bool StormByte::Buffer::Pumper::EoF ( ) const
noexcept

Whether the owned Bridge reports EoF.

Returns
true on EoF or if moved-from.

◆ Failed()

bool StormByte::Buffer::Pumper::Failed ( ) const
noexcept

Whether the owned Bridge failed for real.

Returns
Sticky. Not set by Cancel or move-from.

◆ operator=() [1/2]

Pumper & StormByte::Buffer::Pumper::operator= ( const Pumper &  )
delete

◆ operator=() [2/2]

Pumper & StormByte::Buffer::Pumper::operator= ( Pumper &&  other)
noexcept

Move assignment.

Moved-from is empty and joined.

Parameters
otherInstance to take from.
Returns
*this.

◆ ReadTelemetry()

const StormByte::Shared< StormByte::Buffer::ReadTelemetry > StormByte::Buffer::Pumper::ReadTelemetry ( ) const
noexcept

Read counters copied from the owned Bridge.

Returns
Const shared handle. Empty if moved-from.

◆ Toggle()

void StormByte::Buffer::Pumper::Toggle ( )
noexcept

Pause or resume the worker.

No-op if Failed or Canceled.

◆ WriteTelemetry()

const StormByte::Shared< StormByte::Buffer::WriteTelemetry > StormByte::Buffer::Pumper::WriteTelemetry ( ) const
noexcept

Write counters copied from the owned Bridge.

Returns
Const shared handle. Empty if moved-from.

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