23 std::shared_ptr<DomainWatcher>
const& watcher)
34 auto& runtime = flow->info.runtime;
41 throw std::runtime_error{
"Invalid last committed event."};
53 throw std::runtime_error{
"Invalid recovered event timestamp."};
56 std::atomic_ref{runtime.lastWriteTime}.store(
currentTime(
Clock::TAI).value, std::memory_order_release);
57 std::atomic_ref{runtime.headIndex}.store(next, std::memory_order_release);
62 throw std::runtime_error{
"Invalid next event during writer recovery."};
68 std::atomic_ref{flow->state.syncCounter}.fetch_add(1, std::memory_order_release);
69 wakeAll(&flow->state.syncCounter);
81 MXL_ERROR(
"Bug: exception while removing flow writer from watcher in destructor");
91 throw std::runtime_error{
"No open flow."};
100 throw std::runtime_error{
"No open flow."};
180 auto& runtime = flow->info.runtime;
188 std::atomic_ref{runtime.lastWriteTime}.store(
currentTime(
Clock::TAI).value, std::memory_order_release);
189 std::atomic_ref{runtime.headIndex}.store(
index, std::memory_order_release);
192 std::atomic_ref{flow->state.syncCounter}.fetch_add(1, std::memory_order_release);
193 wakeAll(&flow->state.syncCounter);
Internal shared-memory headers for discrete grains and event slots.
POSIX event writer declaration and private publication state.
Backend contract for a single event producer with private write staging. Callers guarantee one writer...
@ Pending
The requested entry is not yet published or its index is unrepresentable.
@ Ready
Metadata and payload form a validated snapshot of the requested entry.
static std::uint64_t load(std::uint64_t const &value) noexcept
Load a shared 64-bit word with acquire ordering, including from a read-only mapping.
constexpr mxlFlowInfo * flowInfo() noexcept
virtual bool isExclusive() const override
std::vector< std::uint8_t > _payload
Private staging buffer; publication copies only eventSize bytes.
virtual mxlFlowRuntimeInfo getFlowRuntimeInfo() const override
std::uint64_t _lastTimestamp
Last committed timestamp, restored from the ring on attachment.
virtual ~PosixEventFlowWriter() override
Unregister from the watcher and release mappings and the common flow lock.
virtual bool makeExclusive() override
virtual mxlStatus cancel() override
Discard an open write without advancing the queue or timestamp.
virtual FlowData const & getFlowData() const override
std::shared_ptr< DomainWatcher > _watcher
Watcher kept alive while the writer is registered.
virtual mxlStatus commit(mxlEventInfo const &info) override
Publish the staged bytes as one complete event or fragment.
std::unique_ptr< EventFlowData > _flowData
Owns common metadata, ring mappings and the common flow lock.
bool _open
True while one caller-owned write transaction is open.
virtual mxlStatus openEvent(mxlEventInfo *info, std::uint8_t **payload) override
Begin a write and reset metadata to the event defaults.
virtual mxlFlowInfo getFlowInfo() const override
PosixEventFlowWriter(FlowManager const &manager, uuids::uuid const &flowId, std::unique_ptr< EventFlowData > &&data, std::shared_ptr< DomainWatcher > const &watcher)
Attach the sole writer, recover an interrupted publication and restore timestamp ordering.
virtual mxlFlowConfigInfo getFlowConfigInfo() const override
Public flow reader, writer, payload and synchronization APIs.
struct mxlEventInfo_t mxlEventInfo
Metadata for one event queue entry, either a complete event or a fragment.
@ MXL_EVENT_REGISTRY_TYPE_MXL
Namespaced application DIT strings, such as x-mxl:example.
struct mxlFlowRuntimeInfo_t mxlFlowRuntimeInfo
struct mxlFlowConfigInfo_t mxlFlowConfigInfo
struct mxlFlowInfo_t mxlFlowInfo
mxlStatus
MXL SDK Status codes.
void wakeAll(T const *in_addr)
constexpr auto EVENT_HEADER_VERSION
Version stored in the public mxlEventInfo metadata of every published entry.
#define MXL_UNDEFINED_INDEX
uint32_t version
Structure version, currently 1.
uint32_t size
Size of this structure.
uint32_t eventSize
Number of payload bytes published in this entry, possibly zero. For fragments this is the fragment si...
uint32_t flags
Reserved; must be zero.
uint64_t timestamp
Application supplied TAI timestamp in nanoseconds since the epoch; must not decrease within a flow.
mxlFlowRuntimeInfo runtime
gInfo flags
Mark the grain as invalid.