Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
time.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef IMPALA_UTIL_TIME_H
16 #define IMPALA_UTIL_TIME_H
17 
18 #include <stdint.h>
19 #include <time.h>
20 
22 namespace impala {
23 
29 inline int64_t MonotonicMicros() { // 63 bits ~= 5K years uptime
30  struct timespec now;
31  clock_gettime(CLOCK_MONOTONIC, &now);
32  return now.tv_sec * 1000000 + now.tv_nsec / 1000;
33 }
34 
35 inline int64_t MonotonicMillis() {
36  struct timespec now;
37  clock_gettime(CLOCK_MONOTONIC, &now);
38  return now.tv_sec * 1000 + now.tv_nsec / 1000000;
39 }
40 
41 inline int64_t MonotonicSeconds() {
42  struct timespec now;
43  clock_gettime(CLOCK_MONOTONIC, &now);
44  return now.tv_sec;
45 }
46 
51 inline int64_t UnixMillis() {
52  struct timespec now;
53  clock_gettime(CLOCK_REALTIME, &now);
54  return now.tv_sec * 1000 + now.tv_nsec / 1000000;
55 }
56 
58 void SleepForMs(const int64_t duration_ms);
59 
60 }
61 
62 #endif
void SleepForMs(const int64_t duration_ms)
Sleeps the current thread for at least duration_ms milliseconds.
Definition: time.cc:21
int64_t UnixMillis()
Definition: time.h:51
int64_t MonotonicMillis()
Definition: time.h:35
int64_t MonotonicSeconds()
Definition: time.h:41
int64_t MonotonicMicros()
Definition: time.h:29