From: Mike Crowe <mac@mcrowe.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc: Mike Crowe <mac@mcrowe.com>
Subject: [PATCH 06/11] libstdc++ testsuite: Move slow_clock to its own header
Date: Sat, 28 Sep 2019 08:48:00 -0000 [thread overview]
Message-ID: <26a4c450153a0990134d6b234b5161123543a4ee.1569660153.git-series.mac@mcrowe.com> (raw)
In-Reply-To: <cover.401206917148c9c806e008aa7336564a639de964.1569660153.git-series.mac@mcrowe.com>
Move slow_clock test class into a header file so that it can be used by
other tests in the future.
* testsuite/util/slow_clock.h: New file. Move implementation of
slow_clock test class.
* testsuite/30_threads/condition_variable/members/2.cc: Include
slow_clock from header.
---
libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc | 17 +----------------
libstdc++-v3/testsuite/util/slow_clock.h | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 16 deletions(-)
create mode 100644 libstdc++-v3/testsuite/util/slow_clock.h
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc
index cbac3fa..f821d3f 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc
@@ -25,6 +25,7 @@
#include <condition_variable>
#include <system_error>
#include <testsuite_hooks.h>
+#include <slow_clock.h>
template <typename ClockType>
void test01()
@@ -52,22 +53,6 @@ void test01()
}
}
-struct slow_clock
-{
- using rep = std::chrono::system_clock::rep;
- using period = std::chrono::system_clock::period;
- using duration = std::chrono::system_clock::duration;
- using time_point = std::chrono::time_point<slow_clock, duration>;
- static constexpr bool is_steady = false;
-
- static time_point now()
- {
- auto real = std::chrono::system_clock::now();
- return time_point{real.time_since_epoch() / 3};
- }
-};
-
-
void test01_alternate_clock()
{
try
diff --git a/libstdc++-v3/testsuite/util/slow_clock.h b/libstdc++-v3/testsuite/util/slow_clock.h
new file mode 100644
index 0000000..13fc94b
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/slow_clock.h
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004-2019 Free Software Foundation, Inc.
+
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3, or (at
+// your option) any later version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// A clock that ticks at a third of the speed of system_clock that can be used
+// to ensure that functions with timeouts don't erroneously return early.
+
+#include <chrono>
+
+struct slow_clock
+{
+ using rep = std::chrono::system_clock::rep;
+ using period = std::chrono::system_clock::period;
+ using duration = std::chrono::system_clock::duration;
+ using time_point = std::chrono::time_point<slow_clock, duration>;
+ static constexpr bool is_steady = false;
+
+ static time_point now()
+ {
+ auto real = std::chrono::system_clock::now();
+ return time_point{real.time_since_epoch() / 3};
+ }
+};
--
git-series 0.9.1
next prev parent reply other threads:[~2019-09-28 8:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-28 8:45 [PATCH 00/11] timed_mutex, shared_timed_mutex: Add full steady clock support Mike Crowe
2019-09-28 8:45 ` [PATCH 01/11] libstdc++ testsuite: Check return value from timed_mutex::try_lock_until Mike Crowe
2019-09-28 8:45 ` [PATCH 07/11] PR libstdc++/91906 Fix timed_mutex::try_lock_until on arbitrary clock Mike Crowe
2019-09-28 8:45 ` [PATCH 03/11] libstdc++ testsuite: Also test timed_mutex with steady_clock Mike Crowe
2019-09-28 8:45 ` [PATCH 05/11] PR libstdc++/78237 Add full steady_clock support to timed_mutex Mike Crowe
2019-09-28 8:45 ` [PATCH 09/11] libstdc++ shared_mutex: Add full steady_clock support to shared_timed_mutex Mike Crowe
2019-09-28 8:48 ` [PATCH 11/11] shared_mutex: Fix try_lock_until and try_lock_shared_until on arbitrary clock Mike Crowe
2019-09-28 8:48 ` [PATCH 02/11] libstdc++ testsuite: Add timed_mutex::try_lock_until test Mike Crowe
2019-09-28 8:48 ` [PATCH 08/11] libstdc++ testsuite: Also test shared_timed_mutex with steady_clock Mike Crowe
2019-09-28 8:48 ` [PATCH 04/11] libstdc++ testsuite: Also test unique_lock::try_lock_until " Mike Crowe
2019-09-28 8:48 ` Mike Crowe [this message]
2019-09-28 8:48 ` [PATCH 10/11] libstdc++ timed_mutex: Ensure that try_lock_for waits for long enough Mike Crowe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=26a4c450153a0990134d6b234b5161123543a4ee.1569660153.git-series.mac@mcrowe.com \
--to=mac@mcrowe.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).