![]() |
Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
|
Fixed-capacity rolling window of network round-trip time samples. More...
#include <latency_tracker.h>
Classes | |
| struct | Stats |
Public Member Functions | |
| void | addSample (qint64 ms) |
| Stats | stats () const |
| QList< qint64 > | recentSamples () const |
| Snapshot of the current window in chronological order (oldest first). | |
| void | clear () |
Static Public Attributes | |
| static constexpr int | WindowSize = 64 |
Private Attributes | |
| std::array< qint64, WindowSize > | samples {} |
| int | head = 0 |
| index where the next sample will be written | |
| int | count = 0 |
| number of valid samples, capped at WindowSize | |
Fixed-capacity rolling window of network round-trip time samples.
The hot path (addSample) is a single array store and is intentionally free of allocations, locks, or signal emissions so that recording one sample per completed command cannot affect gameplay performance. Aggregate statistics are only computed on demand in stats(), which callers should throttle.
| void LatencyTracker::addSample | ( | qint64 | ms | ) |
| void LatencyTracker::clear | ( | ) |
| QList< qint64 > LatencyTracker::recentSamples | ( | ) | const |
Snapshot of the current window in chronological order (oldest first).
| LatencyTracker::Stats LatencyTracker::stats | ( | ) | const |
|
private |
number of valid samples, capped at WindowSize
|
private |
index where the next sample will be written
|
private |
|
staticconstexpr |