14 header->size =
sizeof *header;
15 header->eventCount =
count;
16 header->payloadSize = payloadSize;
17 auto slotMemory =
static_cast<std::uint8_t*
>(memory) +
sizeof(
EventRingHeader);
19 auto const payloadWordCount = (payloadSize +
sizeof(std::uint64_t) - 1) /
sizeof(std::uint64_t);
20 for (
auto i = std::size_t{0}; i <
count; ++i, slotMemory += stride)
22 auto event = std::construct_at(
reinterpret_cast<Event*
>(slotMemory));
24 event->header.size =
sizeof event->header;
25 event->header.sequence =
EMPTY;
26 std::uninitialized_value_construct_n(
payloadWords(*event), payloadWordCount);
Atomic single-producer event ring storage and snapshot protocol.
static void initialize(void *memory, std::uint32_t count, std::uint32_t payloadSize)
Construct headers, empty sequence tags and payload words in a fresh mapping.
static constexpr auto EMPTY
Tag identifying a slot with no publication.
static std::uint64_t * payloadWords(Event &event) noexcept
Locate the atomic payload words immediately after an event slot header.
static void validateGeometry(std::uint32_t count, std::uint32_t payloadSize)
Validate slot count, payload capacity and mapping-size limits.
static constexpr std::size_t slotStride(std::uint32_t payloadSize) noexcept
Compute the physical stride between adjacent slots.
static constexpr auto STORAGE_VERSION
Version used by immutable ring and slot headers.
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.
Fixed part of an event slot; its payload follows immediately in the mapping.