From efcc43e57928960775b9ec2b1984a73f5330a7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:46:40 +0200 Subject: [PATCH] ASSERTS --- nano/core_test/asio.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nano/core_test/asio.cpp b/nano/core_test/asio.cpp index 5e362b7173..724028a258 100644 --- a/nano/core_test/asio.cpp +++ b/nano/core_test/asio.cpp @@ -37,11 +37,14 @@ TEST (asio, multithreaded_context) std::atomic read_counter{ 0 }; auto reader_coro = [&] (asio::ip::tcp::socket socket) -> asio::awaitable { + debug_assert (strand.running_in_this_thread ()); + std::cout << "reader started" << std::endl; while (true) { std::array buffer; + debug_assert (strand.running_in_this_thread ()); auto size = co_await socket.async_read_some (asio::buffer (buffer), asio::use_awaitable); read_counter += size; } @@ -55,10 +58,13 @@ TEST (asio, multithreaded_context) std::vector readers; auto acceptor_coro = [&] (asio::ip::tcp::acceptor & acceptor) -> asio::awaitable { + debug_assert (strand.running_in_this_thread ()); + std::cout << "listening started" << std::endl; while (true) { + debug_assert (strand.running_in_this_thread ()); auto socket = co_await acceptor.async_accept (asio::use_awaitable); std::cout << "accepted connection" << std::endl; @@ -76,6 +82,8 @@ TEST (asio, multithreaded_context) auto acceptor_fut = asio::co_spawn (strand, acceptor_coro (acceptor), asio::use_future); auto sender_coro = [&] () -> asio::awaitable { + debug_assert (strand.running_in_this_thread ()); + std::cout << "sender started" << std::endl; asio::ip::tcp::socket socket{ strand }; @@ -84,6 +92,7 @@ TEST (asio, multithreaded_context) std::array buffer; while (true) { + debug_assert (strand.running_in_this_thread ()); co_await socket.async_write_some (asio::buffer (buffer), asio::use_awaitable); } };