26 explicit ReplayGate(std::function<uint64_t()> position = {}) : position_(std::move(position)) {}
31 if (open_.load(std::memory_order_relaxed)) {
34 open_index_ = position_ ? position_() : 0;
35 open_.store(
true, std::memory_order_release);
39 [[nodiscard]]
bool is_open_at(uint64_t index)
const noexcept {
40 return open_.load(std::memory_order_acquire) && index >= open_index_;
43 [[nodiscard]]
bool is_open() const noexcept {
return open_.load(std::memory_order_acquire); }
46 std::function<uint64_t()> position_;
47 uint64_t open_index_ = 0;
48 std::atomic<bool> open_{
false};
56 void set(std::shared_ptr<ReplayGate> gate) {
57 gate_ = std::move(gate);
60 [[nodiscard]]
bool gated() const noexcept {
return gate_ !=
nullptr; }
62 [[nodiscard]]
bool publishing() const noexcept {
return !gate_ || opened_; }
70 if (!gate_ || opened_ || !gate_->is_open_at(position_)) {
78 std::shared_ptr<ReplayGate> gate_;
80 uint64_t position_ = 0;
A publisher channel's view of the gate: whether it may publish yet, for the md_queue frame it is work...
bool publishing() const noexcept
False while a gate is closed (or not yet open for the frame being read).
bool opened_now() noexcept
True once, when the gate has opened for the frames now being read: the moment the channel starts publ...
void set(std::shared_ptr< ReplayGate > gate)
Call before the channel is used. A channel with a gate publishes nothing until it opens.
bool gated() const noexcept
void set_position(uint64_t index) noexcept
The md_queue index of the next frame the publisher thread will read.
void open() noexcept
Exchange thread, after its last write to md_queue for the held book.
bool is_open() const noexcept
bool is_open_at(uint64_t index) const noexcept
True once open, for a publisher that is about to read the md_queue frame at index.
ReplayGate(std::function< uint64_t()> position={})
position returns the md_queue's write index (see slick::queue::initial_reading_index),...