Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
srfm::stream::SignalConsumer Class Reference

JSON output thread owner. Non-copyable, non-movable. More...

#include <signal_consumer.hpp>

Public Types

using Ring = SPSCRing< StreamRelativisticSignal, RING_SIZE >
 

Public Member Functions

 SignalConsumer (Ring &ring, FILE *sink=stdout) noexcept
 Construct bound to the output ring and an I/O sink.
 
 ~SignalConsumer () noexcept
 
 SignalConsumer (const SignalConsumer &)=delete
 
SignalConsumer & operator= (const SignalConsumer &)=delete
 
 SignalConsumer (SignalConsumer &&)=delete
 
SignalConsumer & operator= (SignalConsumer &&)=delete
 
void start () noexcept
 Launch the consumer thread. Idempotent.
 
void stop () noexcept
 Stop the consumer thread and perform a final flush. Idempotent.
 
bool running () const noexcept
 Whether the consumer thread is currently running.
 
void write_one (const StreamRelativisticSignal &sig) noexcept
 Serialise one signal to the sink immediately.
 
void flush () noexcept
 Flush the output sink.
 
SignalConsumerCounters counters () const noexcept
 
FILE * sink () const noexcept
 

Static Public Attributes

static constexpr std::size_t RING_SIZE = 65536
 
static constexpr std::size_t FLUSH_INTERVAL = 100
 Flush every N signals.
 

Detailed Description

JSON output thread owner. Non-copyable, non-movable.

SignalConsumer consumer{out_ring}; // writes to stdout
consumer.start();
// ...
consumer.stop();
Lock-free single-producer / single-consumer ring buffer.
Definition spsc_ring.hpp:85
JSON output thread owner. Non-copyable, non-movable.

Definition at line 66 of file signal_consumer.hpp.

Member Typedef Documentation

◆ Ring

Definition at line 71 of file signal_consumer.hpp.

Constructor & Destructor Documentation

◆ SignalConsumer() [1/3]

srfm::stream::SignalConsumer::SignalConsumer ( Ring &  ring,
FILE *  sink = stdout 
)
inlineexplicitnoexcept

Construct bound to the output ring and an I/O sink.

Parameters
ringRing populated by SignalProcessor (non-owning ref).
sinkOutput stream (default: stdout). Must remain valid for the lifetime of this SignalConsumer.

Definition at line 80 of file signal_consumer.hpp.

◆ ~SignalConsumer()

srfm::stream::SignalConsumer::~SignalConsumer ( )
inlinenoexcept

Definition at line 84 of file signal_consumer.hpp.

◆ SignalConsumer() [2/3]

srfm::stream::SignalConsumer::SignalConsumer ( const SignalConsumer &  )
delete

◆ SignalConsumer() [3/3]

srfm::stream::SignalConsumer::SignalConsumer ( SignalConsumer &&  )
delete

Member Function Documentation

◆ counters()

SignalConsumerCounters srfm::stream::SignalConsumer::counters ( ) const
inlinenoexcept

Definition at line 124 of file signal_consumer.hpp.

◆ flush()

void srfm::stream::SignalConsumer::flush ( )
inlinenoexcept

Flush the output sink.

Calls std::fflush(sink_). noexcept.

Definition at line 120 of file signal_consumer.hpp.

◆ operator=() [1/2]

SignalConsumer & srfm::stream::SignalConsumer::operator= ( const SignalConsumer &  )
delete

◆ operator=() [2/2]

SignalConsumer & srfm::stream::SignalConsumer::operator= ( SignalConsumer &&  )
delete

◆ running()

bool srfm::stream::SignalConsumer::running ( ) const
inlinenoexcept

Whether the consumer thread is currently running.

Definition at line 100 of file signal_consumer.hpp.

◆ sink()

FILE * srfm::stream::SignalConsumer::sink ( ) const
inlinenoexcept

Definition at line 128 of file signal_consumer.hpp.

◆ start()

void srfm::stream::SignalConsumer::start ( )
noexcept

Launch the consumer thread. Idempotent.

Definition at line 37 of file signal_consumer.cpp.

◆ stop()

void srfm::stream::SignalConsumer::stop ( )
noexcept

Stop the consumer thread and perform a final flush. Idempotent.

Definition at line 48 of file signal_consumer.cpp.

◆ write_one()

void srfm::stream::SignalConsumer::write_one ( const StreamRelativisticSignal &  sig)
noexcept

Serialise one signal to the sink immediately.

Does not flush. Useful in unit tests.

Parameters
sigSignal to serialise.

Definition at line 58 of file signal_consumer.cpp.

Member Data Documentation

◆ FLUSH_INTERVAL

constexpr std::size_t srfm::stream::SignalConsumer::FLUSH_INTERVAL = 100
staticconstexpr

Flush every N signals.

Definition at line 69 of file signal_consumer.hpp.

◆ RING_SIZE

constexpr std::size_t srfm::stream::SignalConsumer::RING_SIZE = 65536
staticconstexpr

Definition at line 68 of file signal_consumer.hpp.


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