|
StormByte C++ Library: Buffer module 1.2.0
StormByte-Buffer is the buffer module of the StormByte C++ suite.
|
This repository is StormByte Buffer: FIFO, SharedFIFO, Ring, Producer/Consumer, Hopper, Sink and pipelines for the StormByte C++ suite.
It depends on StormByte Base 1.2.0 or newer and optionally StormByte Logger 1.2.0 or newer for pipeline stages (Scope). Public headers live under StormByte/buffer/.
The suite is split on purpose. Base, Config, Crypto, Database, Logger, Multimedia, Network and System are other repositories. This one does not implement them.
Read / Peek keep data; Extract consumes it.Read / Extract block until data or Close / SetError.shared_mutex, many-to-many).Ring.Push / Pop stay; << / >> are the same operations. Notify(cv) does not own the CV; call Unnotify before that CV dies.To(key) / >> / <<. Bind is a [[deprecated]] wrapper. Round-robin or custom Select, plus terminal producer Drain.ExternalReader to ExternalWriter.ExecutionMode: Sync, Async, Parallel (combinable). A non-null logger is scoped as Buffer/Pipeline before it reaches the stages.Close(), SetError(), EoF(), IsReadable(), IsWritable().LockFreeRing is SPSC only, used between pipeline stages.| Module | Role | API |
|---|---|---|
| Base | Exceptions, Expected, serialization, strings, UUID, concepts | /StormByte |
| Buffer | This repository | /StormByte-Buffer |
| Config | Human-readable text and versioned binary documents (groups, lists, raw bytes) | /StormByte-Config |
| Crypto | Hash, compress, encrypt, sign and key agreement — Crypto++ never leaves the private tree | /StormByte-Crypto |
| Database | One API over SQLite, PostgreSQL and MariaDB | /StormByte-Database |
| Logger | Stream logger with levels, headers, hierarchical components and Scope | /StormByte-Logger |
| Multimedia | Decode, encode and containers without raw FFmpeg types; codecs enabled only if present | /StormByte-Multimedia |
| Network | Framed packets, Client/Server, IPv4/IPv6 TCP and Buffer pipelines (compress/encrypt) | /StormByte-Network |
| System | Processes, pipes and environment variables across Linux, Windows and macOS | /StormByte-System |
Needs a C++26 compiler, CMake 3.28 or newer, StormByte Base 1.2.0 or newer, and optionally StormByte Logger 1.2.0 or newer when pipeline stages take a logger.
Headers are #include <StormByte/buffer/….hxx>. Namespace root is StormByte::Buffer.
FIFO is not thread-safe. Concurrent writers/readers use SharedFIFO or Ring.
Prefer these over touching SharedFIFO / Ring by hand.
Hopper<T> is a single-producer single-consumer (SPSC) queue for discrete typed items (StormByte::Type::MoveConstructible T). Capacity 0 is unbounded; Push blocks when a bounded hopper is full. Eof() ends production. Smart pointer types (StormByte::Type::SmartPointer<T>) discard null items on Push.
Push and Pop are the stable API. hopper << item, hopper >> item and item >> hopper do the same thing.
Notify(cv) stores a pointer to a condition variable the Hopper does not own. The Hopper outlives a typical consumer. Call Unnotify() before that CV is destroyed, otherwise a later producer Eof can signal a freed object.
Sink<T> maps integer keys to Hopper<T> buckets. Wire a consumer with To(key) / >> / <<. Bind is the old name and is [[deprecated]].
Sink::EoF() contract:
true only if this Sink was closed (Eof() or destruction).true when every hopper is empty and Hopper::EoF() is true, even if this Sink did not call Eof() (the producer may have closed a shared hopper).EoF() was true may make EoF() false again.Stages receive ExternalReader&, ExternalWriter& and an optional std::shared_ptr<Logger::Log>. They must out.Close() or out.SetError().
When Process gets a non-null logger it passes log->Scope("Buffer/Pipeline") to every stage. c is then Buffer/Pipeline, or Multimedia/Buffer/Pipeline if the caller already scoped a parent. Do not pre-scope Buffer/Pipeline on the argument. A stage that needs a leaf can log->Scope("Decode").
ExecutionMode: Sync (caller thread), Async (background), Parallel (one thread per stage). Flags combine (Async | Parallel).
StormByte is developed in spare time. Sponsorship is optional and does not buy features, priority or support.
Issues only on this repository. Fork and open a pull request against master.
GNU Lesser General Public License version 3 or later. See [LICENSE](LICENSE) and https://www.gnu.org/licenses/lgpl-3.0.html.
StormByte is developed in spare time. Sponsorship is optional and does not buy features, priority or support.