0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fast_clock.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3
9  * of the License.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #include <Common/Compat.h>
28 
29 #include "fast_clock.h"
30 
31 extern "C" {
32 #include <sys/time.h>
33 }
34 
35 using namespace std;
36 
38  struct timeval tv;
39  gettimeofday(&tv, nullptr);
40  return chrono::fast_clock::time_point(chrono::microseconds((tv.tv_sec * 1000000LL) + tv.tv_usec));
41 }
42 
44  return (time_t)(__t.time_since_epoch().count() % 1000000LL);
45 }
46 
48  return chrono::fast_clock::time_point(chrono::microseconds(__t * 1000000LL));
49 }
static time_point from_time_t(time_t __t) noexcept
Definition: fast_clock.cc:47
chrono::time_point< fast_clock > time_point
Definition: fast_clock.h:42
Declarations for fast_clock.
STL namespace.
static time_point now() noexcept
Definition: fast_clock.cc:37
Compatibility Macros for C/C++.
static time_t to_time_t(const time_point &__t) noexcept
Definition: fast_clock.cc:43