Skip to content

Commit ec6201c

Browse files
Merge pull request #22 from connectivecpp/develop
Merging develop to main
2 parents f36a4e8 + 23c880f commit ec6201c

9 files changed

+32
-19
lines changed

.github/workflows/build_run_unit_test_cmake.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: create-build-dir
2929
run: mkdir build
3030
- name: configure-cmake
31-
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 ..
31+
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 ..
3232
- name: build
3333
run: cd build && cmake --build . --config $BUILD_TYPE
3434
- name: run-unit-test

.github/workflows/gen_docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: checkout
1919
uses: actions/checkout@v4
2020
- name: run-doxygen
21-
uses: mattnotmitt/doxygen-action@v1.9.8
21+
uses: mattnotmitt/doxygen-action@v1.12.0
2222
with:
2323
working-directory: doc
2424
- name: deploy-pages

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 by Cliff Green
1+
# Copyright (c) 2024-2025 by Cliff Green
22
#
33
# https://github.com/connectivecpp/wait-queue
44
#

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
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.
2020

21+
[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.
22+
2123
Thanks go to [Louis Langholtz](https://github.com/louis-langholtz) for adding DBC (Design by Contract) asserts and comments.
2224

2325
Concepts and various type constraints have been added. Enhancements are always appreciated.

cmake/download_cpm.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
file(
66
DOWNLOAD
7-
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.39.0/CPM.cmake
7+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.8/CPM.cmake
88
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
99
)
1010
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

example/CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 by Cliff Green
1+
# Copyright (c) 2024-2025 by Cliff Green
22
#
33
# Distributed under the Boost Software License, Version 1.0.
44
# (See accompanying file LICENSE.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
@@ -8,15 +8,23 @@ cmake_minimum_required ( VERSION 3.14 FATAL_ERROR )
88
# create project
99
project ( wait_queue_example LANGUAGES CXX )
1010

11-
# add executable
11+
# add dependencies
12+
CPMAddPackage ( "gh:connectivecpp/[email protected]" )
13+
14+
# add executables
1215
add_executable ( wait_queue_example wait_queue_example.cpp )
1316
target_compile_features ( wait_queue_example PRIVATE cxx_std_20 )
1417

18+
add_executable ( threaded_queue_buffer_demo threaded_queue_buffer_demo.cpp )
19+
target_compile_features ( threaded_queue_buffer_demo PRIVATE cxx_std_20 )
20+
1521
set ( CMAKE_THREAD_PREFER_PTHREAD TRUE )
1622
set ( THREADS_PREFER_PTHREAD_FLAG TRUE )
1723
find_package ( Threads REQUIRED )
1824

1925
# link dependencies
2026
target_link_libraries ( wait_queue_example PRIVATE
2127
Threads::Threads wait_queue )
28+
target_link_libraries ( threaded_queue_buffer_demo PRIVATE
29+
Threads::Threads shared_buffer wait_queue )
2230

example/threaded_queue_buffer_demo.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* Copyright (c)2019 by Thurman Gillespy
88
* 3/22/19
99
*
10+
* Minor changes Apr 2025 by Cliff Green to match changed APIs.
11+
*
1012
* Distributed under the Boost Software License, Version 1.0.
1113
* (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1214
*
@@ -26,7 +28,7 @@
2628
#include <ctime> // std::time
2729

2830
#include "queue/wait_queue.hpp"
29-
#include "marshall/shared_buffer.hpp"
31+
#include "buffer/shared_buffer.hpp"
3032

3133

3234
/** Project Overview

test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 by Cliff Green
1+
# Copyright (c) 2024-2025 by Cliff Green
22
#
33
# Distributed under the Boost Software License, Version 1.0.
44
# (See accompanying file LICENSE.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

test/wait_queue_test.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <set>
2020
#include <optional>
2121
#include <chrono>
22+
#include <ranges> // std::views::iota
2223
#include <type_traits> // std::is_arithmetic
2324

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

48-
for (int i {0}; i < count; ++i) {
49+
for (int i : std::ranges::iota_view{0, count}) {
4950
REQUIRE(wq.push(val));
5051
}
5152
REQUIRE_FALSE (wq.empty());
5253
REQUIRE (wq.size() == count);
53-
for (int i {0}; i < count; ++i) {
54+
for (int i : std::ranges::iota_view{0, count}) {
5455
auto ret = wq.try_pop();
5556
REQUIRE(*ret == val);
5657
}
@@ -69,22 +70,22 @@ void non_threaded_arithmetic_test(Q& wq, int count) {
6970

7071
REQUIRE (wq.empty());
7172

72-
for (int i {0}; i < count; ++i) {
73+
for (int i : std::ranges::iota_view{0, count}) {
7374
REQUIRE(wq.push(base_val));
7475
}
7576
val_type sum { 0 };
7677
wq.apply( [&sum] (const val_type& x) { sum += x; } );
7778
REQUIRE (sum == expected_sum);
7879

79-
for (int i {0}; i < count; ++i) {
80+
for (int i : std::ranges::iota_view{0, count}) {
8081
REQUIRE(*(wq.try_pop()) == base_val);
8182
}
8283
REQUIRE (wq.empty());
8384

84-
for (int i {0}; i < count; ++i) {
85+
for (int i : std::ranges::iota_view{0, count}) {
8586
wq.push(base_val+i);
8687
}
87-
for (int i {0}; i < count; ++i) {
88+
for (int i : std::ranges::iota_view{0, count}) {
8889
REQUIRE(*(wq.try_pop()) == (base_val+i));
8990
}
9091
REQUIRE (wq.size() == 0);
@@ -389,25 +390,25 @@ TEST_CASE ( "Fixed size ring_span, testing wrap around with int type",
389390
constexpr int Answer = 42;
390391
constexpr int AnswerPlus = 42+5;
391392

392-
for (int i {0}; i < N; ++i) {
393+
for (int i : std::ranges::iota_view{0, N}) {
393394
wq.push(Answer);
394395
}
395396
REQUIRE (wq.size() == N);
396397
wq.apply([Answer] (const int& i) { REQUIRE(i == Answer); } );
397398

398-
for (int i {0}; i < N; ++i) {
399+
for (int i : std::ranges::iota_view{0, N}) {
399400
wq.push(Answer);
400401
}
401-
for (int i {0}; i < (N/2); ++i) {
402+
for (int i : std::ranges::iota_view{0, N/2}) {
402403
wq.push(AnswerPlus);
403404
}
404405
// the size is full but half match answer and half answer plus, since there's been wrap
405406
REQUIRE (wq.size() == N);
406407
// wait_pop should immediately return if the queue is non empty
407-
for (int i {0}; i < (N/2); ++i) {
408+
for (int i : std::ranges::iota_view{0, N/2}) {
408409
REQUIRE (wq.wait_and_pop() == Answer);
409410
}
410-
for (int i {0}; i < (N/2); ++i) {
411+
for (int i : std::ranges::iota_view{0, N/2}) {
411412
REQUIRE (wq.wait_and_pop() == AnswerPlus);
412413
}
413414
REQUIRE (wq.empty());

0 commit comments

Comments
 (0)