VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
bag_reader_processor.h File Reference

Time-ordered message buffer for smoothing bag playback across split files. More...

#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
#include <string>
#include "../base/bytes.h"
#include "../impl/types.h"
Include dependency graph for bag_reader_processor.h:

Go to the source code of this file.

Classes

 Time-sorted message relay that buffers and orders messages before delivery. More...
 Configuration for the time-ordered message cache. More...

Namespaces

Detailed Description

Time-ordered message buffer for smoothing bag playback across split files.

BagReaderProcessor accepts messages pushed from one or more BagReader instances and delivers them to an OutputCallback in ascending timestamp order. It uses a time-windowed cache to absorb out-of-order messages that can arise when reading consecutive split files concurrently.

The processor maintains an internal sorted queue. Messages are held for at least Config::min_cache_time milliseconds before being flushed, allowing late-arriving messages from the current split to be sorted before delivery.

Typical usage
processor.register_output_callback([](int64_t ts, const std::string& url,
vlink::ActionType action, const vlink::Bytes& data) {
// process in order
});
// Feed from multiple readers:
reader_a->register_output_callback([&](auto ts, auto& url, auto action, auto& data) {
processor.push(ts, url, action, data);
});
reader_b->register_output_callback([&](auto ts, auto& url, auto action, auto& data) {
processor.push(ts, url, action, data);
});