Skip to content

Commit fef2de1

Browse files
Massive update for dependencies including Catch2, Asio, and Connective C++ libraries
1 parent 7ee0351 commit fef2de1

29 files changed

+79
-66
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ add_library ( chops::chops_net_ip ALIAS chops_net_ip )
3030
# dependencies needed for main library
3131

3232
include ( cmake/download_cpm.cmake )
33-
CPMAddPackage ( "gh:connectivecpp/shared-buffer@1.0.3" )
33+
CPMAddPackage ( "gh:connectivecpp/shared-buffer@1.0.4" )
3434
CPMAddPackage ( "gh:martinmoene/expected-lite@0.8.0" )
3535

3636
include ( cmake/download_asio_cpm.cmake )

include/net_ip/detail/net_entity_common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @author Cliff Green
1919
*
20-
* Copyright (c) 2017-2019 by Cliff Green
20+
* Copyright (c) 2017-2025 by Cliff Green
2121
*
2222
* Distributed under the Boost Software License, Version 1.0.
2323
* (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -27,7 +27,7 @@
2727
#ifndef NET_ENTITY_COMMON_HPP_INCLUDED
2828
#define NET_ENTITY_COMMON_HPP_INCLUDED
2929

30-
#include "asio/executor.hpp"
30+
#include "asio/any_io_executor.hpp"
3131
#include "asio/post.hpp"
3232

3333
#include <atomic>
@@ -75,7 +75,7 @@ class net_entity_common {
7575

7676
template <typename F1, typename F2, typename SF>
7777
std::error_code start(F1&& io_state_chg_func, F2&& err_func,
78-
const asio::executor& exec,
78+
const asio::any_io_executor& exec,
7979
SF&& start_func) {
8080
int expected = 0;
8181
if (!m_started.compare_exchange_strong(expected, 1)) {
@@ -95,7 +95,7 @@ class net_entity_common {
9595

9696

9797
template <typename SF>
98-
std::error_code stop(const asio::executor& exec,
98+
std::error_code stop(const asio::any_io_executor& exec,
9999
SF&& stop_func) {
100100
int expected = 1;
101101
if (!m_started.compare_exchange_strong(expected, 2)) {

include/net_ip/detail/output_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
* Concurrency protection is needed at a higher level to enforce data structure and flag
88
* consistency for data sending, as well as to ensure that only one write is in process at
99
* a time. There are multiple ways to accomplish this goal, whether with locks (mutex or
10-
* spin-lock or semaphore, etc), or by posting all write operations through the Asio
10+
* spin-lock or semaphore, etc), or by posting all write operations through the @c asio
1111
* executor.
1212
*
1313
* @note For internal use only.
1414
*
1515
* @author Cliff Green
1616
*
17-
* Copyright (c) 2017-2019 by Cliff Green
17+
* Copyright (c) 2017-2025 by Cliff Green
1818
*
1919
* Distributed under the Boost Software License, Version 1.0.
2020
* (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

include/net_ip/detail/tcp_connector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @author Cliff Green
1010
*
11-
* Copyright (c) 2018-2019 by Cliff Green
11+
* Copyright (c) 2018-2025 by Cliff Green
1212
*
1313
* Distributed under the Boost Software License, Version 1.0.
1414
* (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

include/net_ip/detail/tcp_io.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define TCP_IO_HPP_INCLUDED
2020

2121
#include "asio/io_context.hpp"
22-
#include "asio/executor.hpp"
22+
#include "asio/any_io_executor.hpp"
2323
#include "asio/read.hpp"
2424
#include "asio/read_until.hpp"
2525
#include "asio/write.hpp"

include/net_ip/net_ip.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ namespace net {
9494
* other words, no event loop or @c run methods are available. Instead, the
9595
* @c net_ip class takes an @c asio @c io_context as a constructor parameter and
9696
* application code will use the @c asio executor methods for invoking
97-
* the underlying asynchronous operations.
97+
* the underlying asynchronous operations. The most current (as of early 2025)
98+
* @c asio executor class, matching the C++ 26 standard executor, is the @c asio
99+
* @c any_io_executor class.
100+
*
98101
*
99102
* For convenience, a class named @c worker in the @c net_ip_component directory
100103
* combines an executor with a work guard and creates a thread to invoke the asynchronous
@@ -391,13 +394,13 @@ class net_ip {
391394
// overloaded utility brought in from net_entity.hpp
392395
std::visit (detail::overloaded {
393396
[this] (detail::tcp_acceptor_weak_ptr p) {
394-
std::erase_if(m_acceptors, [p] (detail::tcp_acceptor_shared_ptr sp) { sp == p.lock(); } )
397+
std::erase_if(m_acceptors, [p] (detail::tcp_acceptor_shared_ptr sp) { return sp == p.lock(); } );
395398
},
396399
[this] (detail::tcp_connector_weak_ptr p) {
397-
std::erase_if(m_connectors, [p] (detail::tcp_connector_shared_ptr sp) { sp == p.lock(); } )
400+
std::erase_if(m_connectors, [p] (detail::tcp_connector_shared_ptr sp) { return sp == p.lock(); } );
398401
},
399402
[this] (detail::udp_entity_io_weak_ptr p) {
400-
std::erase_if(m_udp_entities, [p] (detail::udp_entity_io_shared_ptr sp) { sp == p.lock(); } )
403+
std::erase_if(m_udp_entities, [p] (detail::udp_entity_io_shared_ptr sp) { return sp == p.lock(); } );
401404
}
402405
}, ent.m_wptr);
403406
}

include/net_ip_component/worker.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @author Cliff Green
1111
*
12-
* Copyright (c) 2018 by Cliff Green
12+
* Copyright (c) 2018-2025 by Cliff Green
1313
*
1414
* Distributed under the Boost Software License, Version 1.0.
1515
* (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -25,7 +25,7 @@
2525
#include <iostream>
2626

2727
#include "asio/io_context.hpp"
28-
#include "asio/executor.hpp"
28+
#include "asio/any_io_executor.hpp"
2929
#include "asio/executor_work_guard.hpp"
3030

3131
namespace chops {

test/net_ip/basic_io_output_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <memory> // std::shared_ptr
1717
#include <set>
1818
#include <cstddef> // std::size_t
19+
#include <span>
1920

2021
#include "net_ip/queue_stats.hpp"
2122
#include "net_ip/basic_io_interface.hpp"
@@ -56,7 +57,8 @@ void basic_io_output_test_sends() {
5657
REQUIRE ((*s).output_queue_size == chops::test::io_handler_mock::qs_base);
5758
REQUIRE ((*s).bytes_in_output_queue == (chops::test::io_handler_mock::qs_base + 1));
5859

59-
chops::const_shared_buffer buf(nullptr, 0);
60+
std::byte b { 0x0 };
61+
chops::const_shared_buffer buf(std::span<const std::byte>(&b, 0u));
6062
using endp_t = typename IOT::endpoint_type;
6163

6264
REQUIRE (io_out.is_valid());

test/net_ip/detail/io_common_test.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <chrono>
2222
#include <functional> // std::cref, std::ref
2323
#include <cstddef> // std::size_t
24+
#include <ranges> // std::views::iota
2425

2526
#include "net_ip/detail/io_common.hpp"
2627

@@ -103,14 +104,14 @@ template <typename E>
103104
std::size_t start_writes(const std::vector<E>& data_vec,
104105
chops::net::detail::io_common<E>& io_comm,
105106
int multiplier, int wait_offset) {
106-
chops::repeat(multiplier, [&data_vec, &io_comm, wait_offset] {
107-
for (const auto& e : data_vec) {
108-
auto r = io_comm.start_write(e, empty_write_func<E>);
109-
assert (r != chops::net::detail::io_common<E>::write_status::io_stopped);
110-
}
111-
std::this_thread::sleep_for(std::chrono::milliseconds(Wait+wait_offset));
112-
assert (io_comm.is_io_started());
113-
} );
107+
for (int i : std::views::iota(0, multiplier)) {
108+
for (const auto& e : data_vec) {
109+
auto r = io_comm.start_write(e, empty_write_func<E>);
110+
assert (r != chops::net::detail::io_common<E>::write_status::io_stopped);
111+
}
112+
std::this_thread::sleep_for(std::chrono::milliseconds(Wait+wait_offset));
113+
assert (io_comm.is_io_started());
114+
}
114115
return data_vec.size() * multiplier;
115116
}
116117

@@ -132,11 +133,11 @@ void io_common_stress_test(const std::vector<E>& data_vec, int multiplier, int n
132133

133134
std::vector<std::future<std::size_t>> futs;
134135

135-
chops::repeat(num_thrs, [&iocommon, multiplier, &data_vec, &futs] (int i) {
136+
for (int i : std::views::iota(0, num_thrs)) {
136137
futs.push_back(std::async(std::launch::async, start_writes<E>,
137138
std::cref(data_vec), std::ref(iocommon),
138139
multiplier, 2*i));
139-
} );
140+
}
140141

141142
std::size_t tot = 0u;
142143
for (auto& fut : futs) {
@@ -149,10 +150,10 @@ void io_common_stress_test(const std::vector<E>& data_vec, int multiplier, int n
149150

150151
futs.clear();
151152

152-
chops::repeat(num_thrs, [&iocommon, &data_vec, &futs] {
153+
for (int i : std::views::iota(0, num_thrs)) {
153154
futs.push_back(std::async(std::launch::async, write_next_elems<E>,
154155
std::cref(data_vec), std::ref(iocommon)));
155-
} );
156+
}
156157

157158
for (auto& fut : futs) {
158159
tot += fut.get(); // join threads

test/net_ip/detail/output_queue_test.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <vector>
1717
#include <cassert>
18+
#include <ranges> // std::views::iota
1819

1920
#include "net_ip/detail/output_queue.hpp"
2021

@@ -26,11 +27,11 @@ template <typename E>
2627
std::size_t add_to_q(const std::vector<E>& data_vec,
2728
chops::net::detail::output_queue<E>& outq,
2829
int multiplier) {
29-
chops::repeat(multiplier, [&data_vec, &outq] {
30-
for (const auto& i : data_vec) {
31-
outq.add_element(i);
32-
}
33-
} );
30+
for (int i : std::views::iota(0, multiplier)) {
31+
for (const auto& j : data_vec) {
32+
outq.add_element(j);
33+
}
34+
}
3435
return data_vec.size() * multiplier;
3536
}
3637

@@ -46,12 +47,11 @@ void output_queue_test(const std::vector<E>& data_vec, int multiplier) {
4647
REQUIRE (qs.output_queue_size == tot);
4748
REQUIRE (qs.bytes_in_output_queue == chops::test::accum_io_buf_size(data_vec) * multiplier);
4849

49-
chops::repeat(static_cast<int>(tot), [&outq] {
50-
auto e = outq.get_next_element();
51-
// REQUIRE (e);
52-
assert (e);
53-
}
54-
);
50+
for (int i : std::views::iota(0, static_cast<int>(tot))) {
51+
auto e = outq.get_next_element();
52+
// REQUIRE (e);
53+
assert (e);
54+
}
5555
auto e = outq.get_next_element(); // should be empty optional
5656
REQUIRE_FALSE (e); // no element val available
5757
qs = outq.get_queue_stats();

0 commit comments

Comments
 (0)