2
0
mirror of https://github.com/boostorg/atomic.git synced 2026-01-19 04:02:09 +00:00

Use absolute timeouts for sleeping in wait test helpers.

This may improve the precision of timing of thread wakeups.
This commit is contained in:
Andrey Semashev
2025-06-05 13:26:13 +03:00
parent 39f8c3213d
commit bbe9234f8f
2 changed files with 6 additions and 6 deletions

View File

@@ -92,12 +92,12 @@ public:
test_clock::time_point start_time = test_clock::now();
std::this_thread::sleep_for(chrono::milliseconds(200));
std::this_thread::sleep_until(start_time + chrono::milliseconds(200));
m_wrapper.a.store(m_value2, boost::memory_order_release);
m_wrapper.a.notify_one();
std::this_thread::sleep_for(chrono::milliseconds(200));
std::this_thread::sleep_until(start_time + chrono::milliseconds(400));
m_wrapper.a.store(m_value3, boost::memory_order_release);
m_wrapper.a.notify_one();
@@ -226,7 +226,7 @@ public:
test_clock::time_point start_time = test_clock::now();
std::this_thread::sleep_for(chrono::milliseconds(200));
std::this_thread::sleep_until(start_time + chrono::milliseconds(200));
m_wrapper.a.store(m_value2, boost::memory_order_release);
m_wrapper.a.notify_all();

View File

@@ -89,12 +89,12 @@ public:
test_clock::time_point start_time = test_clock::now();
std::this_thread::sleep_for(chrono::milliseconds(200));
std::this_thread::sleep_until(start_time + chrono::milliseconds(200));
m_wrapper.a.store(m_value2, boost::memory_order_release);
m_wrapper.a.notify_one();
std::this_thread::sleep_for(chrono::milliseconds(200));
std::this_thread::sleep_until(start_time + chrono::milliseconds(400));
m_wrapper.a.store(m_value3, boost::memory_order_release);
m_wrapper.a.notify_one();
@@ -213,7 +213,7 @@ public:
test_clock::time_point start_time = test_clock::now();
std::this_thread::sleep_for(chrono::milliseconds(200));
std::this_thread::sleep_until(start_time + chrono::milliseconds(200));
m_wrapper.a.store(m_value2, boost::memory_order_release);
m_wrapper.a.notify_all();