Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Namespaces
tick_ingester.cpp File Reference

TickIngester implementation — ingestion thread body. More...

#include "../../include/srfm/stream/tick_ingester.hpp"
#include <thread>

Go to the source code of this file.

Namespaces

namespace  srfm
 
namespace  srfm::stream
 

Detailed Description

TickIngester implementation — ingestion thread body.

See include/srfm/stream/tick_ingester.hpp for the full module contract.

Hot-path design

The inner loop in run_loop() is:

  1. Call source_.read() — returns optional<OHLCVTick> or nullopt
  2. If nullopt and source closed → exit loop
  3. If nullopt and source open → yield and continue (spin with backoff)
  4. Validate via tick_is_valid()
  5. Push to ring1_
  6. Update counters

All operations are noexcept. No heap allocation occurs in the loop.

Backoff strategy

When source_.read() returns nullopt (no data available), we call std::this_thread::yield() to be cooperative with the OS scheduler rather than burning a core in a tight spin. A more aggressive variant could use _mm_pause() on x86 or std::this_thread::sleep_for(0ns), but yield() gives a reasonable balance between latency and CPU utilisation for this use-case.

Definition in file tick_ingester.cpp.