VLink  2.0.0
A high-performance communication middleware
vlink::BagProcessor类 参考

Time-sorted relay buffer keyed on the data-plane time, shared by read- and write-side plugins. 更多...

#include <bag_processor.h>

vlink::BagProcessor 的协作图:

struct  Config
 Tunables controlling the reorder buffer behaviour. 更多...
 

Public 类型

using OutputCallback = FrameCallback
 Sink receiving one Frame in data-plane-time order on the worker thread. 更多...
 

Public 成员函数

 BagProcessor (const Config &config=Config())
 Builds the processor. 更多...
 
 ~BagProcessor ()
 Drains remaining frames in data-plane-time order and joins the worker thread. 更多...
 
void register_output_callback (OutputCallback &&output_callback)
 Sets the sink receiving reordered frames and starts the worker thread. 更多...
 
void push (int64_t data_timestamp, const Frame &frame)
 Inserts a frame into the data-plane-time-sorted cache. 更多...
 
void flush ()
 Synchronously drains every currently-buffered frame to the sink, in data-plane-time order. 更多...
 

详细描述

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.

成员类型定义说明

◆ OutputCallback

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.

构造及析构函数说明

◆ BagProcessor()

vlink::BagProcessor::BagProcessor ( const Config config = Config())
explicit

Builds the processor.

参数
configCache time-window and memory-budget tunables.

◆ ~BagProcessor()

vlink::BagProcessor::~BagProcessor ( )

Drains remaining frames in data-plane-time order and joins the worker thread.

成员函数说明

◆ flush()

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.

◆ push()

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_timestampReorder key in microseconds (the data-plane time), or negative when missing.
frameFrame to cache; Frame::timestamp is the canonical time before remapping.

◆ register_output_callback()

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_callbackSink invoked once per frame on the worker thread.

该类的文档由以下文件生成: