18template <
size_t MessageCapacity>
27 std::array<uint8_t, MessageCapacity>
data{};
38 assert(!slots_.empty());
39 auto &slot = slots_[seq % slots_.size()];
45 [[nodiscard]]
const Slot *
find(uint32_t seq)
const noexcept {
46 if (seq == 0 || slots_.empty()) {
49 const auto &slot = slots_[seq % slots_.size()];
50 return slot.seq == seq ? &slot :
nullptr;
57 [[nodiscard]]
bool holds(uint32_t from, uint32_t count)
const noexcept {
58 for (uint64_t i = 0; i < count; ++i) {
59 if (!
find(
static_cast<uint32_t
>(from + i))) {
68 for (
auto &slot : slots_) {
76 [[nodiscard]]
bool empty() const noexcept {
return slots_.empty(); }
77 [[nodiscard]]
size_t capacity() const noexcept {
return slots_.size(); }
80 std::vector<Slot> slots_;
bool holds(uint32_t from, uint32_t count) const noexcept
True when every message in [from, from + count) is still held.
void resize(size_t capacity)
Slot & claim(uint32_t seq) noexcept
Claims seq's slot and returns it for the message to be encoded into.
const Slot * find(uint32_t seq) const noexcept
The message sent as seq, or null when it never was or has been overwritten.
void clear() noexcept
Forgets every message, keeping the slots.
bool empty() const noexcept
size_t capacity() const noexcept
void swap(RetransmitRing &other) noexcept
RetransmitRing(size_t capacity)
RetransmitRing()=default
Empty, with no slots: holds nothing until resized.
uint16_t replay_flag_offset
The byte a replay sets on its copy of the message: iLink 3's PossRetransFlag, or ICE BOE's header fla...
std::array< uint8_t, MessageCapacity > data