]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/util/slow_clock.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / slow_clock.h
CommitLineData
a7334019
MC
1// -*- C++ -*-
2
a945c346 3// Copyright (C) 2018-2024 Free Software Foundation, Inc.
a7334019
MC
4
5// This library is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License as
7// published by the Free Software Foundation; either version 3, or (at
8// your option) any later version.
9
10// This library is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14
15// You should have received a copy of the GNU General Public License
16// along with this library; see the file COPYING3. If not see
17// <http://www.gnu.org/licenses/>.
18
19
20// A clock that ticks at a third of the speed of system_clock that can be used
21// to ensure that functions with timeouts don't erroneously return early.
22
23#include <chrono>
24
bf1fc37b
JW
25namespace __gnu_test
26{
a7334019
MC
27struct slow_clock
28{
29 using rep = std::chrono::system_clock::rep;
30 using period = std::chrono::system_clock::period;
31 using duration = std::chrono::system_clock::duration;
32 using time_point = std::chrono::time_point<slow_clock, duration>;
33 static constexpr bool is_steady = false;
34
35 static time_point now()
36 {
37 auto real = std::chrono::system_clock::now();
38 return time_point{real.time_since_epoch() / 3};
39 }
40};
bf1fc37b 41}