SnapshotChain class
#include <GGUI/Public/Snapshot.h>
SnapshotChain: the latest snapshot, published by one thread and read by others.
Lock-free, and wait-free for the writer: publishing never waits on a reader. Readers lock the latest snapshot; the writer fills one nobody holds and makes it the latest. There is always one more snapshot than possible holders, so the writer always has one to fill. Up to MaxReaders readers may hold a snapshot at once.
Public static variables
- static uint32_t MaxReaders constexpr
- the input thread and the render thread
- static uint32_t SnapshotCount constexpr
- snapshots kept
Public functions
- auto BeginWrite() -> GGSnapshot*
- Writer: an unheld snapshot to fill and pass to Publish. Null if more than MaxReaders readers hold snapshots (the publish is skipped and counted).
- void Publish()
- Writer: make the snapshot from BeginWrite the latest.
- auto Read() const -> SnapshotRead
- Lock the latest snapshot. Any thread.
- auto PublishedCount() const -> uint64_t
- How many snapshots were published.
- auto SkippedCount() const -> uint64_t
- How many publishes were skipped because every snapshot was held.
- auto Bytes() const -> size_t
- Memory held by all snapshots, shared rows counted once. Writer only.