Repository navigation
This release makes misuse of spsc::Queue easier to catch. It tightens which types the queue accepts, adds debug-build assertions, detects stale transactions, and reworks the CMake package as header-only.
⚠️ Breaking changes
- Stricter element type requirements (#15).
ValueLikenow rejectsconst,volatile, reference, and non-default-constructible types.volatile-qualified types are newly rejected.Queue<volatile T, N>worked in 0.1.1 and must now be written asQueue<T, N>. The queue synchronizes through atomics, sovolatileadded nothing.- For
const, reference, and non-default-constructible types, the error just appears earlier. You could never create or use queues of these types, and they now fail at the constraint check instead of at instantiation.
- CMake:
CXXQueueis now anINTERFACE(header-only) library (#21). No compiled library is built or installed any more. Consumers that linkspsc::Queuedon't need to change anything. - CMake: minimum version raised from 3.15 to 3.21 (#21).
- CMake: the test option is renamed (#21).
BUILD_TESTINGis nowCXXQUEUE_BUILD_TESTING. It defaults toONonly when CXXQueue is the top-level project, so pulling CXXQueue in withadd_subdirectory/FetchContentno longer builds its tests or requires GoogleTest.
Safety and correctness
- Stale transactions are detected (#17).
WriteTransaction::commit()andReadTransaction::commit()now check whether the write or read position has moved since the transaction began. Committing such a transaction triggers an assertion in debug builds and returnsfalsewhen assertions are disabled; before, it was undefined behavior. Reading from or writing to the spans of a stale transaction is still undefined behavior. - Buffer invariant assertions (#14).
push,pop,peek,discard,beginWrite, andbeginReadnow assert that the write position never runs more thanNahead of the read position. - Missing includes added (#16):
<cassert>,<cstddef>, and<ranges>.
Performance
- Removed
[[unlikely]]hints from data-dependent branches (#19). Whether a transaction wraps around the end of the ring buffer depends on the data, so these hints could mislead the compiler.
Build and packaging
- Swift Package Manager:
NDEBUGis now defined for release builds, so the new assertions are compiled out of release builds (#18). - CMake (#21):
- Requires C++20 via
target_compile_features. - Installs headers under
${CMAKE_INSTALL_INCLUDEDIR}/spsc. - Exports the target as
Queue(used asspsc::Queue). - Warning flags (
-Wall -Wextra//W4) now apply only to the test target, not to consumers. - Project version updated to 0.2.0; it was previously set to an unrelated 0.6.0 (#23).
- Requires C++20 via
Documentation
- Clarified that the statistics member functions (
isFull, etc.) are meant to be called from the producer or consumer. Calling them from another thread while the queue is in use may return arbitrarily wrong values (#20). - Updated
commit(),beginWrite(), andbeginRead()docs to describe how invalid transactions behave.
Internal
- Clearer variable names (
used/free→availableToRead/availableToWrite) (#13). - Minor reformatting (#12).
- More transaction tests, including stale-commit cases (#22).
Full changelog: 0.1.1...0.2.0