38 [[nodiscard]]
Duration delay() const noexcept {
return delay_; }
45 self->
at(self->clock_->now() + self->delay_, m);
58 driver_thread_ = std::this_thread::get_id();
62 if (std::this_thread::get_id() == self->driver_thread_) {
63 self->
at(self->clock_->now() + self->delay_, m);
75 void post(
const ParamUpdateMsg& m) {
76 const std::lock_guard<std::mutex> lock(inbox_mutex_);
78 inbox_pending_.store(
true, std::memory_order_release);
83 if (FASTMM_LIKELY(!inbox_pending_.load(std::memory_order_acquire)))
return;
84 const std::lock_guard<std::mutex> lock(inbox_mutex_);
88 inbox_pending_.store(
false, std::memory_order_release);
91 [[nodiscard]]
bool empty() const noexcept {
return queue_.empty(); }
92 [[nodiscard]] std::size_t
size() const noexcept {
return queue_.size(); }
101 queue_.erase(queue_.begin());
106 std::multimap<std::int64_t, ParamUpdateMsg> queue_;
108 const SimClock* clock_ =
nullptr;
109 std::thread::id driver_thread_{};
110 std::mutex inbox_mutex_;
111 std::vector<ParamUpdateMsg> inbox_;
112 std::atomic<bool> inbox_pending_{
false};
Deterministic clock for sim/backtest/replay. 1 cycle == 1 ns.
Definition time.hpp:338
Timestamp now() const noexcept
Definition time.hpp:342
Definition param_schedule.hpp:33
void set_delay(Duration d) noexcept
Added to the time of updates that arrive through sink() (the slow tier's delay).
Definition param_schedule.hpp:39
Duration delay() const noexcept
Definition param_schedule.hpp:40
Timestamp next_ts() const noexcept
The earliest delivery time (Timestamp::max() when empty).
Definition param_schedule.hpp:96
ParamSink threaded_sink(const SimClock &clock) noexcept
Like sink(), for a schedule that other threads publish to as well: an update from the thread that cal...
Definition param_schedule.hpp:58
void collect()
Driver thread: schedules the posted updates delay() after the clock's time (the clock passed to sink(...
Definition param_schedule.hpp:84
void post(const ParamUpdateMsg &m)
Any thread: holds m until the next collect().
Definition param_schedule.hpp:77
bool empty() const noexcept
Definition param_schedule.hpp:93
ParamSink sink(const SimClock &clock) noexcept
A ParamPublisher sink: each update is delivered delay() after clock's time at the publish.
Definition param_schedule.hpp:42
ParamUpdateMsg pop() noexcept
Removes the earliest update; its recv_ts is the delivery time.
Definition param_schedule.hpp:100
std::size_t size() const noexcept
Definition param_schedule.hpp:94
void at(Timestamp ts, const ParamUpdateMsg &m)
Delivers m at ts; updates with the same time keep the order they were added in.
Definition param_schedule.hpp:36
Event bus message structs (5.5).
Definition strategy_harness.hpp:40
ParamPublisher: builds ParamUpdate messages for a running engine, off the engine thread (ADR-0013).
Where a built update goes; push returns false when it was not accepted (full).
Definition param_publisher.hpp:45
New strategy parameter values (ADR-0013): up to kMaxFields (field index, raw value) pairs,...
Definition messages.hpp:574
EventHeader hdr
Definition messages.hpp:584
std::int64_t ns
Definition time.hpp:46
static constexpr Timestamp max() noexcept
Definition time.hpp:56