Skip to content

Version 0.2.0

Latest

Choose a tag to compare

@sbooth sbooth released this 18 Nov 13:53
eeb14b8

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). ValueLike now rejects const, 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 as Queue<T, N>. The queue synchronizes through atomics, so volatile added 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: CXXQueue is now an INTERFACE (header-only) library (#21). No compiled library is built or installed any more. Consumers that link spsc::Queue don't need to change anything.
  • CMake: minimum version raised from 3.15 to 3.21 (#21).
  • CMake: the test option is renamed (#21). BUILD_TESTING is now CXXQUEUE_BUILD_TESTING. It defaults to ON only when CXXQueue is the top-level project, so pulling CXXQueue in with add_subdirectory/FetchContent no longer builds its tests or requires GoogleTest.

Safety and correctness

  • Stale transactions are detected (#17). WriteTransaction::commit() and ReadTransaction::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 returns false when 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, and beginRead now assert that the write position never runs more than N ahead 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: NDEBUG is 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 as spsc::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).

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(), and beginRead() 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