aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-07-10 16:43:58 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-07-10 16:43:58 -0700
commitd1c925402964f5c1139d71ff7fe5cac97b1ee257 (patch)
tree49cfb2ff68a32ddc5ebfb3e771dcdcc334c25c0a /include
parent25adcaa164780075cf85ae63774e0cae867effff (diff)
parent080d6c50bbed3dde739b2de610023d8bd8d7966f (diff)
Merge pull request #2289 from ctiller/footprints-on-the-sands-of-time
Introduce multiple clocks to GPR
Diffstat (limited to 'include')
-rw-r--r--include/grpc/support/time.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h
index 1fd3181859..a5c947dfc8 100644
--- a/include/grpc/support/time.h
+++ b/include/grpc/support/time.h
@@ -46,8 +46,8 @@ extern "C" {
#endif
typedef struct gpr_timespec {
- time_t tv_sec;
- int tv_nsec;
+ time_t tv_sec;
+ int tv_nsec;
} gpr_timespec;
/* Time constants. */
@@ -62,8 +62,20 @@ extern const gpr_timespec gpr_inf_past; /* The far past. */
#define GPR_NS_PER_US 1000
#define GPR_US_PER_MS 1000
-/* Return the current time measured from the system's default epoch. */
-gpr_timespec gpr_now(void);
+/* The clocks we support. */
+typedef enum {
+ /* Monotonic clock. Epoch undefined. Always moves forwards. */
+ GPR_CLOCK_MONOTONIC = 0,
+ /* Realtime clock. May jump forwards or backwards. Settable by
+ the system administrator. Has its epoch at 0:00:00 UTC 1 Jan 1970. */
+ GPR_CLOCK_REALTIME
+} gpr_clock_type;
+
+/* initialize time subsystem */
+void gpr_time_init(void);
+
+/* Return the current time measured from the given clocks epoch. */
+gpr_timespec gpr_now(gpr_clock_type clock);
/* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
respectively. */
@@ -100,4 +112,4 @@ double gpr_timespec_to_micros(gpr_timespec t);
}
#endif
-#endif /* GRPC_SUPPORT_TIME_H */
+#endif /* GRPC_SUPPORT_TIME_H */