Skip to content

Merging develop to main #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_run_unit_test_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: create-build-dir
run: mkdir build
- name: configure-cmake
run: cd build && cmake -D WAIT_QUEUE_BUILD_TESTS:BOOL=ON -D WAIT_QUEUE_BUILD_EXAMPLES:BOOL=ON -D JM_CIRCULAR_BUFFER_BUILD_TESTS:BOOL=OFF ..
run: cd build && cmake -D CMAKE_POLICY_VERSION_MINIMUM=3.5 -D WAIT_QUEUE_BUILD_TESTS:BOOL=ON -D WAIT_QUEUE_BUILD_EXAMPLES:BOOL=ON -D JM_CIRCULAR_BUFFER_BUILD_TESTS:BOOL=OFF ..
- name: build
run: cd build && cmake --build . --config $BUILD_TYPE
- name: run-unit-test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gen_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: checkout
uses: actions/checkout@v4
- name: run-doxygen
uses: mattnotmitt/doxygen-action@v1.9.8
uses: mattnotmitt/doxygen-action@v1.12.0
with:
working-directory: doc
- name: deploy-pages
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 by Cliff Green
# Copyright (c) 2024-2025 by Cliff Green
#
# https://github.com/connectivecpp/wait-queue
#
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

Shutdown semantics are available through `std::stop_token` facilities. A `std::stop_token` can be passed in through the constructors, allowing shutdown to be requested externally to the `wait_queue`, or shutdown can be requested through the `wait_queue request_stop` method.

[P0260R15 - C++ Concurrent Queues](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p0260r15.html) has recently (February 2025) been accepted by the standards committee for C++ 26. This proposal has more features than `wait_queue`, but much of the API is similar.

Thanks go to [Louis Langholtz](https://github.com/louis-langholtz) for adding DBC (Design by Contract) asserts and comments.

Concepts and various type constraints have been added. Enhancements are always appreciated.
Expand Down
2 changes: 1 addition & 1 deletion cmake/download_cpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.39.0/CPM.cmake
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.8/CPM.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)
12 changes: 10 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 by Cliff Green
# Copyright (c) 2024-2025 by Cliff Green
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -8,15 +8,23 @@ cmake_minimum_required ( VERSION 3.14 FATAL_ERROR )
# create project
project ( wait_queue_example LANGUAGES CXX )

# add executable
# add dependencies
CPMAddPackage ( "gh:connectivecpp/shared-buffer@1.0.2" )

# add executables
add_executable ( wait_queue_example wait_queue_example.cpp )
target_compile_features ( wait_queue_example PRIVATE cxx_std_20 )

add_executable ( threaded_queue_buffer_demo threaded_queue_buffer_demo.cpp )
target_compile_features ( threaded_queue_buffer_demo PRIVATE cxx_std_20 )

set ( CMAKE_THREAD_PREFER_PTHREAD TRUE )
set ( THREADS_PREFER_PTHREAD_FLAG TRUE )
find_package ( Threads REQUIRED )

# link dependencies
target_link_libraries ( wait_queue_example PRIVATE
Threads::Threads wait_queue )
target_link_libraries ( threaded_queue_buffer_demo PRIVATE
Threads::Threads shared_buffer wait_queue )

4 changes: 3 additions & 1 deletion example/threaded_queue_buffer_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Copyright (c)2019 by Thurman Gillespy
* 3/22/19
*
* Minor changes Apr 2025 by Cliff Green to match changed APIs.
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
Expand All @@ -26,7 +28,7 @@
#include <ctime> // std::time

#include "queue/wait_queue.hpp"
#include "marshall/shared_buffer.hpp"
#include "buffer/shared_buffer.hpp"


/** Project Overview
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 by Cliff Green
# Copyright (c) 2024-2025 by Cliff Green
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
Expand Down
23 changes: 12 additions & 11 deletions test/wait_queue_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <set>
#include <optional>
#include <chrono>
#include <ranges> // std::views::iota
#include <type_traits> // std::is_arithmetic

#include <thread>
Expand All @@ -45,12 +46,12 @@ void non_threaded_push_test(Q& wq, const typename Q::value_type& val, int count)
REQUIRE (wq.empty());
REQUIRE (wq.size() == 0);

for (int i {0}; i < count; ++i) {
for (int i : std::ranges::iota_view{0, count}) {
REQUIRE(wq.push(val));
}
REQUIRE_FALSE (wq.empty());
REQUIRE (wq.size() == count);
for (int i {0}; i < count; ++i) {
for (int i : std::ranges::iota_view{0, count}) {
auto ret = wq.try_pop();
REQUIRE(*ret == val);
}
Expand All @@ -69,22 +70,22 @@ void non_threaded_arithmetic_test(Q& wq, int count) {

REQUIRE (wq.empty());

for (int i {0}; i < count; ++i) {
for (int i : std::ranges::iota_view{0, count}) {
REQUIRE(wq.push(base_val));
}
val_type sum { 0 };
wq.apply( [&sum] (const val_type& x) { sum += x; } );
REQUIRE (sum == expected_sum);

for (int i {0}; i < count; ++i) {
for (int i : std::ranges::iota_view{0, count}) {
REQUIRE(*(wq.try_pop()) == base_val);
}
REQUIRE (wq.empty());

for (int i {0}; i < count; ++i) {
for (int i : std::ranges::iota_view{0, count}) {
wq.push(base_val+i);
}
for (int i {0}; i < count; ++i) {
for (int i : std::ranges::iota_view{0, count}) {
REQUIRE(*(wq.try_pop()) == (base_val+i));
}
REQUIRE (wq.size() == 0);
Expand Down Expand Up @@ -389,25 +390,25 @@ TEST_CASE ( "Fixed size ring_span, testing wrap around with int type",
constexpr int Answer = 42;
constexpr int AnswerPlus = 42+5;

for (int i {0}; i < N; ++i) {
for (int i : std::ranges::iota_view{0, N}) {
wq.push(Answer);
}
REQUIRE (wq.size() == N);
wq.apply([Answer] (const int& i) { REQUIRE(i == Answer); } );

for (int i {0}; i < N; ++i) {
for (int i : std::ranges::iota_view{0, N}) {
wq.push(Answer);
}
for (int i {0}; i < (N/2); ++i) {
for (int i : std::ranges::iota_view{0, N/2}) {
wq.push(AnswerPlus);
}
// the size is full but half match answer and half answer plus, since there's been wrap
REQUIRE (wq.size() == N);
// wait_pop should immediately return if the queue is non empty
for (int i {0}; i < (N/2); ++i) {
for (int i : std::ranges::iota_view{0, N/2}) {
REQUIRE (wq.wait_and_pop() == Answer);
}
for (int i {0}; i < (N/2); ++i) {
for (int i : std::ranges::iota_view{0, N/2}) {
REQUIRE (wq.wait_and_pop() == AnswerPlus);
}
REQUIRE (wq.empty());
Expand Down