[03/11] libstdc++ testsuite: Also test timed_mutex with steady_clock

Message ID c9fbf3ce0368b43f70a2ca532bb7cb34da6eb9ef.1569660153.git-series.mac@mcrowe.com
State Superseded
Headers show
Series
  • timed_mutex, shared_timed_mutex: Add full steady clock support
Related show

Commit Message

Mike Crowe Sept. 28, 2019, 8:44 a.m.
* testsuite/30_threads/timed_mutex/try_lock_until/57641.cc:
	  Template test functions and use them to test both steady_clock
	  and system_clock.
---
 libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
git-series 0.9.1

Patch

diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc
index 12ee52f..6355d8f 100644
--- a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc
+++ b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc
@@ -49,18 +49,26 @@  struct clock
 std::timed_mutex mx;
 bool locked = false;
 
+template <typename ClockType>
 void f()
 {
-  locked = mx.try_lock_until(clock::now() + C::milliseconds(1));
+  locked = mx.try_lock_until(ClockType::now() + C::milliseconds(1));
 }
 
-int main()
+template <typename ClockType>
+void test()
 {
   std::lock_guard<std::timed_mutex> l(mx);
-  auto start = C::system_clock::now();
-  std::thread t(f);
+  auto start = ClockType::now();
+  std::thread t(f<ClockType>);
   t.join();
-  auto stop = C::system_clock::now();
+  auto stop = ClockType::now();
   VERIFY( (stop - start) < C::seconds(9) );
   VERIFY( !locked );
 }
+
+int main()
+{
+  test<C::system_clock>();
+  test<C::steady_clock>();
+}