|
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
|
ParamPublisher: builds ParamUpdate messages for a running engine, off the engine thread (ADR-0013). More...
#include "fastmm/core/messages.hpp"#include "fastmm/core/msg_ring.hpp"#include "fastmm/core/strong_id.hpp"#include "fastmm/core/time.hpp"#include "fastmm/strategies/params.hpp"#include <cstddef>#include <cstdint>#include <memory>#include <mutex>#include <optional>#include <stdexcept>#include <string>#include <string_view>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| struct | fastmm::ParamSink |
| Where a built update goes; push returns false when it was not accepted (full). More... | |
| class | fastmm::ParamPublisher |
| struct | fastmm::ParamPublisher::BlockOps |
| Copying and freeing a parameter block whose layout is known only at run time (strategies/hot_params.hpp); validate runs after the schema's parsers. More... | |
| struct | fastmm::ParamPublisher::Value |
| Every parameter of the copy, in schema order: one instrument's, or the shared set. More... | |
Namespaces | |
| namespace | fastmm |
ParamPublisher: builds ParamUpdate messages for a running engine, off the engine thread (ADR-0013).
MsgRing ring(1U << 16); // one of the engine's RingFeed rings ParamPublisher pub(ParamSink::to_ring(ring), strategy.params()); pub.publish({{"half_spread_bps", "7.5"}}); // false: no room in the ring
A publish parses the named values into a copy of the parameters with the schema's parsers and ranges, then runs the params struct's validate(). An unknown name, a name given twice, a value that does not parse or is out of range, a failed validate() and more than ParamUpdateMsg::kMaxFields values throw std::invalid_argument; nothing is sent then. The engine copies the raw values without checks.
The copy starts from the parameters passed to the constructor (read them before the engine thread starts) and follows every update that was sent, so it equals what the engine holds once it has consumed the ring. Parameters an update does not name keep their values. With instruments > 0 the publisher keeps one copy per instrument and an update may name one instrument; a strategy that keeps one parameter set (StrategyBase) publishes to all instruments.
Calls may come from any thread; a mutex serialises them, so the publisher is the ring's only producer. Not for the engine thread: publish allocates.