MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
Flow.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3
7
8#pragma once
9
10#include <cstddef>
11#include <cstdint>
12#include <iosfwd>
13#include <type_traits>
14#include <mxl/flow.h>
15#include <mxl/platform.h>
16#include "FlowState.hpp"
17
18namespace mxl::lib
19{
21 constexpr inline auto FLOW_DATA_VERSION = 1U;
22
24 constexpr inline auto GRAIN_HEADER_VERSION = 1U;
25
35
38 constexpr inline auto const MXL_GRAIN_PAYLOAD_OFFSET = std::size_t{8192};
39
41 {
43
44 std::uint8_t pad[MXL_GRAIN_PAYLOAD_OFFSET - sizeof info];
45 };
46
55 struct Grain
56 {
58 };
59
61 constexpr inline auto EVENT_HEADER_VERSION = std::uint32_t{1};
62
68 {
70 std::uint32_t version;
72 std::uint32_t size;
74 std::uint8_t layoutPadding[128 - 2 * sizeof(std::uint32_t)];
76 std::uint64_t sequence;
78 std::uint8_t sequencePadding[128 - sizeof(std::uint64_t)];
80 std::uint64_t infoWords[sizeof(mxlEventInfo) / sizeof(std::uint64_t)];
81 };
82
83 static_assert(sizeof(EventHeader) == 768);
84 static_assert(offsetof(EventHeader, sequence) == 128);
85 static_assert(offsetof(EventHeader, infoWords) == 256);
86 static_assert(std::has_unique_object_representations_v<EventHeader>);
87
89 struct Event
90 {
92 };
93
94 std::ostream& operator<<(std::ostream& os, Grain const& obj);
95
96} // namespace mxl::lib
Public flow reader, writer, payload and synchronization APIs.
struct mxlGrainInfo_t mxlGrainInfo
struct mxlEventInfo_t mxlEventInfo
Metadata for one event queue entry, either a complete event or a fragment.
struct mxlFlowInfo_t mxlFlowInfo
constexpr auto EVENT_HEADER_VERSION
Version stored in the public mxlEventInfo metadata of every published entry.
Definition Flow.hpp:61
std::ostream & operator<<(std::ostream &os, Grain const &obj)
constexpr auto GRAIN_HEADER_VERSION
The version of the grain header structs in shared memory that we expect an support.
Definition Flow.hpp:24
constexpr auto const MXL_GRAIN_PAYLOAD_OFFSET
Definition Flow.hpp:38
constexpr auto FLOW_DATA_VERSION
The version of the flow data structs in shared memory that we expect and support.
Definition Flow.hpp:21
768-byte slot header with layout fields, sequence and metadata on separate 128-byte boundaries....
Definition Flow.hpp:68
std::uint8_t sequencePadding[128 - sizeof(std::uint64_t)]
Explicit padding to the metadata cache line.
Definition Flow.hpp:78
std::uint64_t sequence
Atomic tag: index shifted left one bit, low bit set after publication; EMPTY if unused.
Definition Flow.hpp:76
std::uint8_t layoutPadding[128 - 2 *sizeof(std::uint32_t)]
Explicit padding to the sequence cache line.
Definition Flow.hpp:74
std::uint32_t size
Immutable size of EventHeader in bytes.
Definition Flow.hpp:72
std::uint64_t infoWords[sizeof(mxlEventInfo)/sizeof(std::uint64_t)]
Public metadata accessed through atomic words.
Definition Flow.hpp:80
std::uint32_t version
Immutable EventRingBuffer storage version.
Definition Flow.hpp:70
Fixed part of an event slot; its payload follows immediately in the mapping.
Definition Flow.hpp:90
EventHeader header
Sequence, layout and metadata fields for this slot.
Definition Flow.hpp:91
mxlFlowInfo info
Definition Flow.hpp:32
mxl::lib::FlowState state
Definition Flow.hpp:33
std::uint8_t pad[MXL_GRAIN_PAYLOAD_OFFSET - sizeof info]
Definition Flow.hpp:44
mxlGrainInfo info
Definition Flow.hpp:42
GrainHeader header
Definition Flow.hpp:57