You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Update changelog with new features and fixes
- Improve README documentation for lossy semantics and loss detection
- Implement loss detection in SlickQueue with debug support
- Add tests for lossy overwrite behavior and loss detection
- Modify CMake to enable loss detection in tests
- `void publish(uint64_t slot, uint32_t n = 1)` - Publish `n` written items to consumers
213
213
- `std::pair<T*, uint32_t> read(uint64_t& cursor)` - Read next available item (independent cursor)
214
214
- `std::pair<T*, uint32_t> read(std::atomic<uint64_t>& cursor)` - Read next available item (shared atomic cursor for work-stealing)
215
215
- `T* read_last()` - Read the most recently published item without a cursor
216
216
- `uint32_t size()` - Get queue capacity
217
+
- `uint64_t loss_count() const` - Get count of skipped items due to overwrite (debug-only if enabled)
217
218
- `void reset()` - Reset the queue, invalidating all existing data
218
219
219
220
### Important Constraints
220
221
221
222
**Lock-Free Atomics Implementation**: SlickQueue uses a packed 64-bit atomic internally to guarantee lock-free operations on all platforms. This packs both the write index (48 bits) and the reservation size (16 bits) into a single atomic value.
222
223
224
+
**Lossy Semantics**: SlickQueue does not apply backpressure. If producers advance by at least the queue size before a consumer reads, older entries will be overwritten and the consumer will skip ahead to the latest value for a slot. Size the queue and read frequency to bound loss.
225
+
226
+
**Debug Loss Detection**: Define `SLICK_QUEUE_ENABLE_LOSS_DETECTION=1` to enable a per-instance skipped-item counter (enabled by default in Debug builds). Use `loss_count()` to inspect how many items were skipped.
227
+
223
228
**⚠️ Reserve Size Limitation**: When using `read_last()`, the number of slots in any `reserve(n)` call **must not exceed 65,535** (2^16 - 1). This is because the size is stored in 16 bits within the packed atomic.
224
229
225
230
- For typical use cases with `reserve()` or `reserve(1)`, this limit is not a concern
0 commit comments