diff --git a/test/atomicity.cpp b/test/atomicity.cpp index 3719d17..4e061e5 100644 --- a/test/atomicity.cpp +++ b/test/atomicity.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2011 Helge Bahmann +// Copyright (c) 2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -36,7 +37,6 @@ #include #include #include "test_config.hpp" -#include "test_clock.hpp" /* helper class to let two instances of a function race against each other, with configurable timeout and early abort on detection of error */ @@ -46,7 +46,7 @@ public: /* concurrently run the function in two threads, until either timeout or one of the functions returns "false"; returns true if timeout was reached, or false if early abort and updates timeout accordingly */ - static bool execute(std::function< bool (std::size_t) > const& fn, steady_clock::duration& timeout) + static bool execute(std::function< bool (std::size_t) > const& fn, std::chrono::steady_clock::duration& timeout) { concurrent_runner runner(fn); runner.wait_finish(timeout); @@ -60,10 +60,10 @@ public: second_thread_ = std::thread([this, fn]() { thread_function(fn, 1); }); } - void wait_finish(steady_clock::duration& timeout) + void wait_finish(std::chrono::steady_clock::duration& timeout) { - steady_clock::time_point start = steady_clock::now(); - steady_clock::time_point end = start + timeout; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point end = start + timeout; { std::unique_lock< std::mutex > guard(m_); @@ -79,7 +79,7 @@ public: first_thread_.join(); second_thread_.join(); - steady_clock::duration duration = steady_clock::now() - start; + std::chrono::steady_clock::duration duration = std::chrono::steady_clock::now() - start; if (duration < timeout) timeout = duration; } @@ -152,7 +152,7 @@ double estimate_avg_race_time(void) /* take 10 samples */ for (std::size_t n = 0; n < 10; ++n) { - steady_clock::duration timeout = std::chrono::seconds(10); + std::chrono::steady_clock::duration timeout = std::chrono::seconds(10); volatile unsigned int value(0); bool success = concurrent_runner::execute( @@ -249,14 +249,14 @@ int main(int, char *[]) double avg_race_time = estimate_avg_race_time(); /* 5.298 = 0.995 quantile of exponential distribution */ - const steady_clock::duration timeout = std::chrono::microseconds(static_cast< std::chrono::microseconds::rep >(5.298 * avg_race_time)); + const std::chrono::steady_clock::duration timeout = std::chrono::microseconds(static_cast< std::chrono::microseconds::rep >(5.298 * avg_race_time)); { boost::atomic value(0); /* testing two different operations in this loop, therefore enlarge timeout */ - steady_clock::duration tmp(timeout * 2); + std::chrono::steady_clock::duration tmp(timeout * 2); bool success = concurrent_runner::execute( [&value](std::size_t instance) { return test_arithmetic< unsigned int, 0 >(value, instance); }, @@ -271,7 +271,7 @@ int main(int, char *[]) /* testing three different operations in this loop, therefore enlarge timeout */ - steady_clock::duration tmp(timeout * 3); + std::chrono::steady_clock::duration tmp(timeout * 3); bool success = concurrent_runner::execute( [&value](std::size_t instance) { return test_bitops< unsigned int, 0 >(value, instance); }, diff --git a/test/atomicity_ref.cpp b/test/atomicity_ref.cpp index c5bdcbe..966c899 100644 --- a/test/atomicity_ref.cpp +++ b/test/atomicity_ref.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Andrey Semashev +// Copyright (c) 2020-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -40,7 +40,6 @@ #include #include #include "test_config.hpp" -#include "test_clock.hpp" /* helper class to let two instances of a function race against each other, with configurable timeout and early abort on detection of error */ @@ -50,7 +49,7 @@ public: /* concurrently run the function in two threads, until either timeout or one of the functions returns "false"; returns true if timeout was reached, or false if early abort and updates timeout accordingly */ - static bool execute(std::function< bool (std::size_t) > const& fn, steady_clock::duration& timeout) + static bool execute(std::function< bool (std::size_t) > const& fn, std::chrono::steady_clock::duration& timeout) { concurrent_runner runner(fn); runner.wait_finish(timeout); @@ -64,10 +63,10 @@ public: second_thread_ = std::thread([this, fn]() { thread_function(fn, 1); }); } - void wait_finish(steady_clock::duration& timeout) + void wait_finish(std::chrono::steady_clock::duration& timeout) { - steady_clock::time_point start = steady_clock::now(); - steady_clock::time_point end = start + timeout; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point end = start + timeout; { std::unique_lock< std::mutex > guard(m_); @@ -83,7 +82,7 @@ public: first_thread_.join(); second_thread_.join(); - steady_clock::duration duration = steady_clock::now() - start; + std::chrono::steady_clock::duration duration = std::chrono::steady_clock::now() - start; if (duration < timeout) timeout = duration; } @@ -156,7 +155,7 @@ double estimate_avg_race_time(void) /* take 10 samples */ for (std::size_t n = 0; n < 10; ++n) { - steady_clock::duration timeout = std::chrono::seconds(10); + std::chrono::steady_clock::duration timeout = std::chrono::seconds(10); volatile unsigned int value(0); bool success = concurrent_runner::execute( @@ -255,14 +254,14 @@ int main(int, char *[]) double avg_race_time = estimate_avg_race_time(); /* 5.298 = 0.995 quantile of exponential distribution */ - const steady_clock::duration timeout = std::chrono::microseconds(static_cast< std::chrono::microseconds::rep >(5.298 * avg_race_time)); + const std::chrono::steady_clock::duration timeout = std::chrono::microseconds(static_cast< std::chrono::microseconds::rep >(5.298 * avg_race_time)); { unsigned int value = 0; /* testing two different operations in this loop, therefore enlarge timeout */ - steady_clock::duration tmp(timeout * 2); + std::chrono::steady_clock::duration tmp(timeout * 2); bool success = concurrent_runner::execute( [&value](std::size_t instance) { return test_arithmetic< unsigned int, 0 >(value, instance); }, @@ -277,7 +276,7 @@ int main(int, char *[]) /* testing three different operations in this loop, therefore enlarge timeout */ - steady_clock::duration tmp(timeout * 3); + std::chrono::steady_clock::duration tmp(timeout * 3); bool success = concurrent_runner::execute( [&value](std::size_t instance) { return test_bitops< unsigned int, 0 >(value, instance); }, diff --git a/test/ipc_wait_test_helpers.hpp b/test/ipc_wait_test_helpers.hpp index 0a605b0..82ea626 100644 --- a/test/ipc_wait_test_helpers.hpp +++ b/test/ipc_wait_test_helpers.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 Andrey Semashev +// Copyright (c) 2020-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -17,10 +17,10 @@ #include #include #include +#include #include #include #include -#include #include "atomic_wrapper.hpp" #include "lightweight_test_stream.hpp" #include "test_clock.hpp" @@ -28,7 +28,7 @@ #include "test_barrier.hpp" //! Since some of the tests below are allowed to fail, we retry up to this many times to pass the test -BOOST_CONSTEXPR_OR_CONST unsigned int test_retry_count = 5u; +constexpr unsigned int test_retry_count = 5u; //! The test verifies that the wait operation returns immediately if the passed value does not match the atomic value template< template< typename > class Wrapper, typename T > @@ -92,22 +92,22 @@ public: test_clock::time_point start_time = test_clock::now(); - std::this_thread::sleep_until(start_time + chrono::milliseconds(200)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(200)); m_wrapper.a.store(m_value2, boost::memory_order_release); m_wrapper.a.notify_one(); - std::this_thread::sleep_until(start_time + chrono::milliseconds(400)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(400)); m_wrapper.a.store(m_value3, boost::memory_order_release); m_wrapper.a.notify_one(); - if (!thread1.try_join_for(chrono::seconds(3))) + if (!thread1.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 1 failed to join"); std::abort(); } - if (!thread2.try_join_for(chrono::seconds(3))) + if (!thread2.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 2 failed to join"); std::abort(); @@ -120,21 +120,24 @@ public: if (m_wrapper.a.has_native_wait_notify()) { - if ((first_state->m_wakeup_time - start_time) < chrono::milliseconds(200)) + if ((first_state->m_wakeup_time - start_time) < std::chrono::milliseconds(200)) { - std::cout << "notify_one_test: first thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_one_test: first thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } - if ((first_state->m_wakeup_time - start_time) >= chrono::milliseconds(400)) + if ((first_state->m_wakeup_time - start_time) >= std::chrono::milliseconds(400)) { - std::cout << "notify_one_test: first thread woke up too late: " << chrono::duration_cast< chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_one_test: first thread woke up too late: " + << std::chrono::duration_cast< std::chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } - if ((second_state->m_wakeup_time - start_time) < chrono::milliseconds(400)) + if ((second_state->m_wakeup_time - start_time) < std::chrono::milliseconds(400)) { - std::cout << "notify_one_test: second thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(second_state->m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_one_test: second thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(second_state->m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } @@ -226,17 +229,17 @@ public: test_clock::time_point start_time = test_clock::now(); - std::this_thread::sleep_until(start_time + chrono::milliseconds(200)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(200)); m_wrapper.a.store(m_value2, boost::memory_order_release); m_wrapper.a.notify_all(); - if (!thread1.try_join_for(chrono::seconds(3))) + if (!thread1.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 1 failed to join"); std::abort(); } - if (!thread2.try_join_for(chrono::seconds(3))) + if (!thread2.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 2 failed to join"); std::abort(); @@ -244,15 +247,17 @@ public: if (m_wrapper.a.has_native_wait_notify()) { - if ((m_thread1_state.m_wakeup_time - start_time) < chrono::milliseconds(200)) + if ((m_thread1_state.m_wakeup_time - start_time) < std::chrono::milliseconds(200)) { - std::cout << "notify_all_test: first thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(m_thread1_state.m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_all_test: first thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(m_thread1_state.m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } - if ((m_thread2_state.m_wakeup_time - start_time) < chrono::milliseconds(200)) + if ((m_thread2_state.m_wakeup_time - start_time) < std::chrono::milliseconds(200)) { - std::cout << "notify_all_test: second thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(m_thread2_state.m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_all_test: second thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(m_thread2_state.m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } } @@ -289,7 +294,7 @@ inline void test_notify_all(T value1, T value2) //! Invokes all wait/notify tests template< template< typename > class Wrapper, typename T > -void test_wait_notify_api_impl(T value1, T value2, T value3, boost::true_type) +void test_wait_notify_api_impl(T value1, T value2, T value3, std::true_type) { test_wait_value_mismatch< Wrapper >(value1, value2); test_notify_one< Wrapper >(value1, value2, value3); @@ -297,7 +302,7 @@ void test_wait_notify_api_impl(T value1, T value2, T value3, boost::true_type) } template< template< typename > class Wrapper, typename T > -inline void test_wait_notify_api_impl(T, T, T, boost::false_type) +inline void test_wait_notify_api_impl(T, T, T, std::false_type) { } @@ -305,7 +310,7 @@ inline void test_wait_notify_api_impl(T, T, T, boost::false_type) template< template< typename > class Wrapper, typename T > inline void test_wait_notify_api(T value1, T value2, T value3) { - test_wait_notify_api_impl< Wrapper >(value1, value2, value3, boost::integral_constant< bool, Wrapper< T >::atomic_type::is_always_lock_free >()); + test_wait_notify_api_impl< Wrapper >(value1, value2, value3, std::integral_constant< bool, Wrapper< T >::atomic_type::is_always_lock_free >()); } //! Invokes all wait/notify tests, if the atomic type is lock-free diff --git a/test/ordering.cpp b/test/ordering.cpp index 90ad677..d16ac9e 100644 --- a/test/ordering.cpp +++ b/test/ordering.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011 Helge Bahmann // Copyright (c) 2012 Tim Blechmann -// Copyright (c) 2023 Andrey Semashev +// Copyright (c) 2023-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -39,7 +39,6 @@ #include #include #include -#include "test_clock.hpp" #include "test_barrier.hpp" // Two threads perform the following operations: @@ -58,7 +57,7 @@ class total_store_order_test public: total_store_order_test(void); - void run(steady_clock::duration& timeout); + void run(std::chrono::steady_clock::duration& timeout); bool detected_conflict(void) const { return detected_conflict_; } private: @@ -97,10 +96,10 @@ total_store_order_test::total_store_order_test(void) : } template -void total_store_order_test::run(steady_clock::duration& timeout) +void total_store_order_test::run(std::chrono::steady_clock::duration& timeout) { - steady_clock::time_point start = steady_clock::now(); - steady_clock::time_point end = start + timeout; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point end = start + timeout; std::thread t1([this]() { this->thread1fn(); }); std::thread t2([this]() { this->thread2fn(); }); @@ -119,7 +118,7 @@ void total_store_order_test::run(steady_clock::duration t2.join(); t1.join(); - steady_clock::duration duration = steady_clock::now() - start; + std::chrono::steady_clock::duration duration = std::chrono::steady_clock::now() - start; if (duration < timeout) timeout = duration; } @@ -235,7 +234,7 @@ void test_seq_cst(void) /* take 10 samples */ for (std::size_t n = 0; n < 10; n++) { - steady_clock::duration timeout = std::chrono::seconds(10); + std::chrono::steady_clock::duration timeout = std::chrono::seconds(10); total_store_order_test test; test.run(timeout); @@ -260,7 +259,7 @@ void test_seq_cst(void) /* 5.298 = 0.995 quantile of exponential distribution */ std::chrono::microseconds timeout_us(static_cast< std::chrono::microseconds::rep >(5.298 * avg_race_time_995)); - steady_clock::duration timeout = timeout_us; + std::chrono::steady_clock::duration timeout = timeout_us; std::cout << "run seq_cst for " << timeout_us.count() << " us\n"; diff --git a/test/ordering_ref.cpp b/test/ordering_ref.cpp index 05e0a4d..8df8afb 100644 --- a/test/ordering_ref.cpp +++ b/test/ordering_ref.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 Andrey Semashev +// Copyright (c) 2020-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -41,7 +41,6 @@ #include #include #include -#include "test_clock.hpp" #include "test_barrier.hpp" // Two threads perform the following operations: @@ -60,7 +59,7 @@ class total_store_order_test public: total_store_order_test(void); - void run(steady_clock::duration& timeout); + void run(std::chrono::steady_clock::duration& timeout); bool detected_conflict(void) const { return detected_conflict_; } private: @@ -101,10 +100,10 @@ total_store_order_test::total_store_order_test(void) : } template -void total_store_order_test::run(steady_clock::duration& timeout) +void total_store_order_test::run(std::chrono::steady_clock::duration& timeout) { - steady_clock::time_point start = steady_clock::now(); - steady_clock::time_point end = start + timeout; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point end = start + timeout; std::thread t1([this]() { this->thread1fn(); }); std::thread t2([this]() { this->thread2fn(); }); @@ -123,7 +122,7 @@ void total_store_order_test::run(steady_clock::duration t2.join(); t1.join(); - steady_clock::duration duration = steady_clock::now() - start; + std::chrono::steady_clock::duration duration = std::chrono::steady_clock::now() - start; if (duration < timeout) timeout = duration; } @@ -239,7 +238,7 @@ void test_seq_cst(void) /* take 10 samples */ for (std::size_t n = 0; n < 10; n++) { - steady_clock::duration timeout = std::chrono::seconds(10); + std::chrono::steady_clock::duration timeout = std::chrono::seconds(10); total_store_order_test test; test.run(timeout); @@ -264,7 +263,7 @@ void test_seq_cst(void) /* 5.298 = 0.995 quantile of exponential distribution */ std::chrono::microseconds timeout_us(static_cast< std::chrono::microseconds::rep >(5.298 * avg_race_time_995)); - steady_clock::duration timeout = timeout_us; + std::chrono::steady_clock::duration timeout = timeout_us; std::cout << "run seq_cst for " << timeout_us.count() << " us\n"; diff --git a/test/test_clock.hpp b/test/test_clock.hpp index 43161bc..4e0bbbf 100644 --- a/test/test_clock.hpp +++ b/test/test_clock.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Andrey Semashev +// Copyright (c) 2020-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -16,14 +16,6 @@ #endif #include -namespace chrono = std::chrono; - -#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 40700 -using steady_clock = chrono::monotonic_clock; -#else -using steady_clock = chrono::steady_clock; -#endif - #if defined(BOOST_WINDOWS) // On Windows high precision clocks tend to cause spurious test failures because threads wake up earlier than expected. @@ -32,8 +24,8 @@ struct test_clock { using rep = long long; using period = std::milli; - using duration = chrono::duration< rep, period >; - using time_point = chrono::time_point< test_clock, duration >; + using duration = std::chrono::duration< rep, period >; + using time_point = std::chrono::time_point< test_clock, duration >; static constexpr bool is_steady = true; @@ -45,7 +37,7 @@ struct test_clock }; #else -using test_clock = steady_clock; +using test_clock = std::chrono::steady_clock; #endif #endif // BOOST_ATOMIC_TEST_TEST_CLOCK_HPP_INCLUDED_ diff --git a/test/test_thread.hpp b/test/test_thread.hpp index f6d159f..24b870a 100644 --- a/test/test_thread.hpp +++ b/test/test_thread.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Andrey Semashev +// Copyright (c) 2023-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -11,7 +11,6 @@ #include #include #include -#include "test_clock.hpp" //! Test thread class with the ability to join the thread with a timeout class test_thread @@ -53,7 +52,7 @@ public: template< typename Rep, typename Period > bool try_join_for(std::chrono::duration< Rep, Period > dur) { - return try_join_until(steady_clock::now() + dur); + return try_join_until(std::chrono::steady_clock::now() + dur); } template< typename Clock, typename Duration > diff --git a/test/wait_fuzz.cpp b/test/wait_fuzz.cpp index 64842fe..1ede593 100644 --- a/test/wait_fuzz.cpp +++ b/test/wait_fuzz.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Andrey Semashev +// Copyright (c) 2020-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -18,12 +18,11 @@ #include #include #include -#include "test_clock.hpp" #include "test_barrier.hpp" boost::atomic< unsigned int > g_atomic(0u); -BOOST_CONSTEXPR_OR_CONST unsigned int loop_count = 4096u; +constexpr unsigned int loop_count = 4096u; void thread_func(test_barrier* barrier) { @@ -52,7 +51,7 @@ int main() barrier.arrive_and_wait(); // Let the threads block on the atomic counter - std::this_thread::sleep_for(chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); while (true) { diff --git a/test/wait_test_helpers.hpp b/test/wait_test_helpers.hpp index 6c402be..09d94e1 100644 --- a/test/wait_test_helpers.hpp +++ b/test/wait_test_helpers.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 Andrey Semashev +// Copyright (c) 2020-2025 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -25,7 +25,7 @@ #include "test_barrier.hpp" //! Since some of the tests below are allowed to fail, we retry up to this many times to pass the test -BOOST_CONSTEXPR_OR_CONST unsigned int test_retry_count = 5u; +constexpr unsigned int test_retry_count = 5u; //! The test verifies that the wait operation returns immediately if the passed value does not match the atomic value template< template< typename > class Wrapper, typename T > @@ -89,22 +89,22 @@ public: test_clock::time_point start_time = test_clock::now(); - std::this_thread::sleep_until(start_time + chrono::milliseconds(200)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(200)); m_wrapper.a.store(m_value2, boost::memory_order_release); m_wrapper.a.notify_one(); - std::this_thread::sleep_until(start_time + chrono::milliseconds(400)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(400)); m_wrapper.a.store(m_value3, boost::memory_order_release); m_wrapper.a.notify_one(); - if (!thread1.try_join_for(chrono::seconds(3))) + if (!thread1.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 1 failed to join"); std::abort(); } - if (!thread2.try_join_for(chrono::seconds(3))) + if (!thread2.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 2 failed to join"); std::abort(); @@ -115,21 +115,24 @@ public: if (second_state->m_wakeup_time < first_state->m_wakeup_time) std::swap(first_state, second_state); - if ((first_state->m_wakeup_time - start_time) < chrono::milliseconds(200)) + if ((first_state->m_wakeup_time - start_time) < std::chrono::milliseconds(200)) { - std::cout << "notify_one_test: first thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_one_test: first thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } - if ((first_state->m_wakeup_time - start_time) >= chrono::milliseconds(400)) + if ((first_state->m_wakeup_time - start_time) >= std::chrono::milliseconds(400)) { - std::cout << "notify_one_test: first thread woke up too late: " << chrono::duration_cast< chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_one_test: first thread woke up too late: " + << std::chrono::duration_cast< std::chrono::milliseconds >(first_state->m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } - if ((second_state->m_wakeup_time - start_time) < chrono::milliseconds(400)) + if ((second_state->m_wakeup_time - start_time) < std::chrono::milliseconds(400)) { - std::cout << "notify_one_test: second thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(second_state->m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_one_test: second thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(second_state->m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } @@ -213,31 +216,33 @@ public: test_clock::time_point start_time = test_clock::now(); - std::this_thread::sleep_until(start_time + chrono::milliseconds(200)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(200)); m_wrapper.a.store(m_value2, boost::memory_order_release); m_wrapper.a.notify_all(); - if (!thread1.try_join_for(chrono::seconds(3))) + if (!thread1.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 1 failed to join"); std::abort(); } - if (!thread2.try_join_for(chrono::seconds(3))) + if (!thread2.try_join_for(std::chrono::seconds(3))) { BOOST_ERROR("Thread 2 failed to join"); std::abort(); } - if ((m_thread1_state.m_wakeup_time - start_time) < chrono::milliseconds(200)) + if ((m_thread1_state.m_wakeup_time - start_time) < std::chrono::milliseconds(200)) { - std::cout << "notify_all_test: first thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(m_thread1_state.m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_all_test: first thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(m_thread1_state.m_wakeup_time - start_time).count() << " ms" << std::endl; return false; } - if ((m_thread2_state.m_wakeup_time - start_time) < chrono::milliseconds(200)) + if ((m_thread2_state.m_wakeup_time - start_time) < std::chrono::milliseconds(200)) { - std::cout << "notify_all_test: second thread woke up too soon: " << chrono::duration_cast< chrono::milliseconds >(m_thread2_state.m_wakeup_time - start_time).count() << " ms" << std::endl; + std::cout << "notify_all_test: second thread woke up too soon: " + << std::chrono::duration_cast< std::chrono::milliseconds >(m_thread2_state.m_wakeup_time - start_time).count() << " ms" << std::endl; return false; }