diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-07-17 15:39:28 -0700 |
---|---|---|
committer | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-07-17 15:39:28 -0700 |
commit | e9881bbaf3d53aa80099c42c80fb3331ff38270a (patch) | |
tree | 1e82a6cf2e32204f9fae78ccc12a936f7471e084 /include | |
parent | 2d883e723178007a33dd88e6f9c0a1e5f7be3e13 (diff) | |
parent | e086725e4cc8c750889ea2c6051795f7d1ecdeca (diff) |
Merge pull request #2403 from ctiller/no-worries-i-can-wait
Add a clock_type field to gpr_timespec
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/completion_queue.h | 3 | ||||
-rw-r--r-- | include/grpc/support/time.h | 42 |
2 files changed, 26 insertions, 19 deletions
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index f32cbff06c..0523ab6a0e 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -105,7 +105,8 @@ class CompletionQueue : public GrpcLibrary { // Returns false if the queue is ready for destruction, true if event bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, gpr_inf_future) != SHUTDOWN); + return (AsyncNextInternal(tag, ok, gpr_inf_future(GPR_CLOCK_REALTIME)) != + SHUTDOWN); } // Shutdown has to be called, and the CompletionQueue can only be diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h index a5c947dfc8..3f375f6ecd 100644 --- a/include/grpc/support/time.h +++ b/include/grpc/support/time.h @@ -45,15 +45,30 @@ extern "C" { #endif +/* 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, + /* Unmeasurable clock type: no base, created by taking the difference + between two times */ + GPR_TIMESPAN +} gpr_clock_type; + typedef struct gpr_timespec { time_t tv_sec; int tv_nsec; + /** Against which clock was this time measured? (or GPR_TIMESPAN if + this is a relative time meaure) */ + gpr_clock_type clock_type; } gpr_timespec; /* Time constants. */ -extern const gpr_timespec gpr_time_0; /* The zero time interval. */ -extern const gpr_timespec gpr_inf_future; /* The far future */ -extern const gpr_timespec gpr_inf_past; /* The far past. */ +gpr_timespec gpr_time_0(gpr_clock_type type); /* The zero time interval. */ +gpr_timespec gpr_inf_future(gpr_clock_type type); /* The far future */ +gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */ #define GPR_MS_PER_SEC 1000 #define GPR_US_PER_SEC 1000000 @@ -62,15 +77,6 @@ extern const gpr_timespec gpr_inf_past; /* The far past. */ #define GPR_NS_PER_US 1000 #define GPR_US_PER_MS 1000 -/* 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); @@ -90,12 +96,12 @@ gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b); /* Return a timespec representing a given number of time units. LONG_MIN is interpreted as gpr_inf_past, and LONG_MAX as gpr_inf_future. */ -gpr_timespec gpr_time_from_micros(long x); -gpr_timespec gpr_time_from_nanos(long x); -gpr_timespec gpr_time_from_millis(long x); -gpr_timespec gpr_time_from_seconds(long x); -gpr_timespec gpr_time_from_minutes(long x); -gpr_timespec gpr_time_from_hours(long x); +gpr_timespec gpr_time_from_micros(long x, gpr_clock_type clock_type); +gpr_timespec gpr_time_from_nanos(long x, gpr_clock_type clock_type); +gpr_timespec gpr_time_from_millis(long x, gpr_clock_type clock_type); +gpr_timespec gpr_time_from_seconds(long x, gpr_clock_type clock_type); +gpr_timespec gpr_time_from_minutes(long x, gpr_clock_type clock_type); +gpr_timespec gpr_time_from_hours(long x, gpr_clock_type clock_type); gpr_int32 gpr_time_to_millis(gpr_timespec timespec); |