[med-svn] [Git][med-team/readerwriterqueue][upstream] New upstream version 1.0.7
Étienne Mollier (@emollier)
gitlab at salsa.debian.org
Fri Feb 27 16:06:41 GMT 2026
Étienne Mollier pushed to branch upstream at Debian Med / readerwriterqueue
Commits:
16d63a03 by Étienne Mollier at 2026-02-27T16:51:10+01:00
New upstream version 1.0.7
- - - - -
6 changed files:
- CMakeLists.txt
- atomicops.h
- readerwritercircularbuffer.h
- readerwriterqueue.h
- + readerwriterqueueConfig.cmake.in
- tests/unittests/unittests.cpp
Changes:
=====================================
CMakeLists.txt
=====================================
@@ -1,11 +1,67 @@
cmake_minimum_required(VERSION 3.9)
-project(readerwriterqueue VERSION 1.0.0)
+project(readerwriterqueue VERSION 1.0.7)
include(GNUInstallDirs)
+include(CMakePackageConfigHelpers)
add_library(${PROJECT_NAME} INTERFACE)
-target_include_directories(readerwriterqueue INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(readerwriterqueue INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/>
+)
install(FILES atomicops.h readerwriterqueue.h readerwritercircularbuffer.h LICENSE.md
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
+
+install(TARGETS ${PROJECT_NAME}
+ EXPORT ${PROJECT_NAME}Targets
+)
+
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
+ VERSION
+ ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ ARCH_INDEPENDENT
+)
+
+configure_package_config_file(${PROJECT_NAME}Config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
+ INSTALL_DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/
+)
+
+install(EXPORT
+ ${PROJECT_NAME}Targets
+ FILE
+ ${PROJECT_NAME}Targets.cmake
+ NAMESPACE
+ "${PROJECT_NAME}::"
+ DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+ COMPONENT
+ Devel
+)
+
+install(
+ FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
+ DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+ COMPONENT
+ Devel
+)
+
+set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
+set(CPACK_PACKAGE_VENDOR "Cameron Desrochers <cameron at moodycamel.com>")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A single-producer, single-consumer lock-free queue for C++.")
+set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
+set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR})
+set(CPACK_GENERATOR "RPM;DEB")
+
+include(CPack)
=====================================
atomicops.h
=====================================
@@ -44,8 +44,18 @@
#define AE_UNUSED(x) ((void)x)
// AE_NO_TSAN/AE_TSAN_ANNOTATE_*
+// For GCC
+#if defined(__SANITIZE_THREAD__)
+#define AE_TSAN_IS_ENABLED
+#endif
+// For clang
#if defined(__has_feature)
-#if __has_feature(thread_sanitizer)
+#if __has_feature(thread_sanitizer) && !defined(AE_TSAN_IS_ENABLED)
+#define AE_TSAN_IS_ENABLED
+#endif
+#endif
+
+#ifdef AE_TSAN_IS_ENABLED
#if __cplusplus >= 201703L // inline variables require C++17
namespace moodycamel { inline int ae_tsan_global; }
#define AE_TSAN_ANNOTATE_RELEASE() AnnotateHappensBefore(__FILE__, __LINE__, (void *)(&::moodycamel::ae_tsan_global))
@@ -56,10 +66,11 @@ extern "C" void AnnotateHappensAfter(const char*, int, void*);
#define AE_NO_TSAN __attribute__((no_sanitize("thread")))
#endif
#endif
-#endif
+
#ifndef AE_NO_TSAN
#define AE_NO_TSAN
#endif
+
#ifndef AE_TSAN_ANNOTATE_RELEASE
#define AE_TSAN_ANNOTATE_RELEASE()
#define AE_TSAN_ANNOTATE_ACQUIRE()
=====================================
readerwritercircularbuffer.h
=====================================
@@ -232,6 +232,27 @@ public:
return wait_dequeue_timed(item, std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
}
+ // Returns a pointer to the next element in the queue (the one that would
+ // be removed next by a call to `try_dequeue` or `try_pop`). If the queue
+ // appears empty at the time the method is called, returns nullptr instead.
+ // Thread-safe when called by consumer thread.
+ inline T* peek()
+ {
+ if (!items->availableApprox())
+ return nullptr;
+ return inner_peek();
+ }
+
+ // Pops the next element from the queue, if there is one.
+ // Thread-safe when called by consumer thread.
+ inline bool try_pop()
+ {
+ if (!items->tryWait())
+ return false;
+ inner_pop();
+ return true;
+ }
+
// Returns a (possibly outdated) snapshot of the total number of elements currently in the buffer.
// Thread-safe.
inline std::size_t size_approx() const
@@ -265,6 +286,18 @@ private:
slots_->signal();
}
+ T* inner_peek()
+ {
+ return reinterpret_cast<T*>(data) + (nextItem & mask);
+ }
+
+ void inner_pop()
+ {
+ std::size_t i = nextItem++;
+ reinterpret_cast<T*>(data)[i & mask].~T();
+ slots_->signal();
+ }
+
template<typename U>
static inline char* align_for(char* ptr)
{
=====================================
readerwriterqueue.h
=====================================
@@ -51,8 +51,8 @@
#ifndef MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE
#if defined (__APPLE__) && defined (__MACH__) && __cplusplus >= 201703L
// This is required to find out what deployment target we are using
-#include <CoreFoundation/CoreFoundation.h>
-#if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
+#include <AvailabilityMacros.h>
+#if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || !defined(MAC_OS_X_VERSION_10_14) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
// C++17 new(size_t, align_val_t) is not backwards-compatible with older versions of macOS, so we can't support over-alignment in this case
#define MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE
#endif
=====================================
readerwriterqueueConfig.cmake.in
=====================================
@@ -0,0 +1,3 @@
+ at PACKAGE_INIT@
+
+include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME at Targets.cmake)
=====================================
tests/unittests/unittests.cpp
=====================================
@@ -704,9 +704,11 @@ public:
for (int iteration = 0; iteration != 128; ++iteration) { // check there's no problem with mismatch between nominal and allocated capacity
ASSERT_OR_FAIL(q.max_capacity() == 65);
ASSERT_OR_FAIL(q.size_approx() == 0);
+ ASSERT_OR_FAIL(!q.try_pop());
ASSERT_OR_FAIL(q.try_enqueue(0));
ASSERT_OR_FAIL(q.max_capacity() == 65);
ASSERT_OR_FAIL(q.size_approx() == 1);
+ ASSERT_OR_FAIL(*q.peek() == 0);
for (int i = 1; i != 65; ++i)
q.wait_enqueue(i);
ASSERT_OR_FAIL(q.size_approx() == 65);
@@ -749,6 +751,20 @@ public:
}
Foo::reset();
+ {
+ Foo item;
+ for (int i = 0; i != 23 + 32; ++i) {
+ ASSERT_OR_FAIL(q.try_enqueue(Foo()));
+ item = std::move(*q.peek());
+ ASSERT_OR_FAIL(q.try_pop());
+ }
+ ASSERT_OR_FAIL(!q.peek());
+ ASSERT_OR_FAIL(!q.try_pop());
+ ASSERT_OR_FAIL(Foo::destroy_count() == 23 + 32);
+ ASSERT_OR_FAIL(Foo::destroyed_in_order());
+ }
+ Foo::reset();
+
{
Foo item;
for (int i = 0; i != 10; ++i)
@@ -790,7 +806,15 @@ public:
SimpleThread reader([&]() {
int item;
for (int i = 0; i != 1000000; ++i) {
- q.wait_dequeue(item);
+ int* peeked = q.peek();
+ if (peeked) {
+ item = *peeked;
+ if (peeked != q.peek() || !q.try_pop())
+ result = 0;
+ }
+ else {
+ q.wait_dequeue(item);
+ }
if (item != i)
result = 0;
}
View it on GitLab: https://salsa.debian.org/med-team/readerwriterqueue/-/commit/16d63a034aca238be7e30e5044c2d7fc4f4d7dd6
--
View it on GitLab: https://salsa.debian.org/med-team/readerwriterqueue/-/commit/16d63a034aca238be7e30e5044c2d7fc4f4d7dd6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20260227/f278b684/attachment-0001.htm>
More information about the debian-med-commit
mailing list