|
VLink 2.0.0
A high-performance communication middleware
|
A high-performance std::ostream backed by a resizable std::string buffer.
More...
Go to the source code of this file.
Classes | |
| class | vlink::FastStream |
High-performance std::ostream with an embedded resizable string buffer. More... | |
Namespaces | |
| namespace | vlink |
A high-performance std::ostream backed by a resizable std::string buffer.
FastStream is a specialised output stream designed for zero-copy, low-latency log formatting inside the VLink Logger. It inherits from std::ostream, so any standard stream manipulator or operator<< overload works transparently.
Key design points:
StringBuf that stores data in a std::string (avoids heap fragmentation for short messages via a pre-allocated capacity).take_view() returns a std::string_view into the internal buffer, enabling zero-copy hand-off to the logger sink without an extra copy.write_raw() bypasses std::ostream formatting and writes bytes directly into the underlying buffer, suitable for pre-formatted C-strings.shrink_to_fit() can reclaim excess memory after an unusually long message.FastStream is not thread-safe. Each thread should own its own instance, which is the pattern used by the Logger (thread_local FastStream).take_view() invalidates any previously taken view after the next write or explicit reset(). Do not hold views across multiple log calls.