|
VLink
2.0.0
A high-performance communication middleware
|
Time-sorted relay buffer keyed on the data-plane time, shared by read- and write-side plugins. More...
#include <bag_processor.h>
Classes | |
| struct | Config |
| Tunables controlling the reorder buffer behaviour. More... | |
Public Types | |
| using | OutputCallback = FrameCallback |
Sink receiving one Frame in data-plane-time order on the worker thread. More... | |
Public Member Functions | |
| BagProcessor (const Config &config=Config()) | |
| Builds the processor. More... | |
| ~BagProcessor () | |
| Drains remaining frames in data-plane-time order and joins the worker thread. More... | |
| void | register_output_callback (OutputCallback &&output_callback) |
| Sets the sink receiving reordered frames and starts the worker thread. More... | |
| void | push (int64_t data_timestamp, const Frame &frame) |
| Inserts a frame into the data-plane-time-sorted cache. More... | |
| void | flush () |
| Synchronously drains every currently-buffered frame to the sink, in data-plane-time order. More... | |
Time-sorted relay buffer keyed on the data-plane time, shared by read- and write-side plugins.
Thread-safe in the sense that push() may be called concurrently from the host's loop thread(s); delivery to the OutputCallback happens on a dedicated worker thread owned by the processor.
Sink receiving one Frame in data-plane-time order on the worker thread.
Invoked once Config::min_cache_time of data-plane time has accumulated ahead of the candidate frame (or a wall-clock drain has fired). The frame is moved out of the cache into the callback. The callback frame timestamp is remapped onto the sorted data-plane-time axis so it stays strictly increasing after the reorder.
Builds the processor.
| config | Cache time-window and memory-budget tunables. |
| vlink::BagProcessor::~BagProcessor | ( | ) |
Drains remaining frames in data-plane-time order and joins the worker thread.
| void vlink::BagProcessor::flush | ( | ) |
Synchronously drains every currently-buffered frame to the sink, in data-plane-time order.
Blocks until the cache is empty: the worker thread emits each queued frame through the registered output callback, then wakes the caller. A plugin forwards this from BagPluginInterface::flush() so buffered tail frames are emitted before teardown. A no-op before callback registration or shutdown.
| void vlink::BagProcessor::push | ( | int64_t | data_timestamp, |
| const Frame & | frame | ||
| ) |
Inserts a frame into the data-plane-time-sorted cache.
Safe to call from any thread after register_output_callback(). Frames are ordered by data_timestamp. Negative data_timestamp is filled from the previous data timestamp and the Frame::timestamp delta; without a previous anchor it stays -1 and sorts first. Output frame timestamps are remapped on the data-time axis and kept strictly increasing. The frame is copied into the owning cache.
| data_timestamp | Reorder key in microseconds (the data-plane time), or negative when missing. |
| frame | Frame to cache; Frame::timestamp is the canonical time before remapping. |
| void vlink::BagProcessor::register_output_callback | ( | OutputCallback && | output_callback | ) |
Sets the sink receiving reordered frames and starts the worker thread.
The first registration before push() takes effect; later registrations are ignored.
| output_callback | Sink invoked once per frame on the worker thread. |