diff options
author | Craig Tiller <ctiller@google.com> | 2015-07-13 09:16:03 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-07-13 09:16:03 -0700 |
commit | 354398f9f5191bb44198b94e1828eafb60de5a67 (patch) | |
tree | 716e16fa3c813b5b02344eba8e341c27fd40840c /src | |
parent | 75cfb044f3c5582a50582c375b443ee4ab029c33 (diff) |
Updating wrapped languages to new time functions
Diffstat (limited to 'src')
-rw-r--r-- | src/cpp/util/time.cc | 2 | ||||
-rw-r--r-- | src/node/ext/completion_queue_async_worker.cc | 3 | ||||
-rw-r--r-- | src/node/ext/server.cc | 3 | ||||
-rw-r--r-- | src/node/ext/timeval.cc | 8 | ||||
-rw-r--r-- | src/python/src/grpc/_adapter/_c/utility.c | 1 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_grpc.c | 13 |
6 files changed, 21 insertions, 9 deletions
diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc index 99b857a428..a814cad452 100644 --- a/src/cpp/util/time.cc +++ b/src/cpp/util/time.cc @@ -59,6 +59,7 @@ void Timepoint2Timespec(const system_clock::time_point& from, nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs); to->tv_sec = secs.count(); to->tv_nsec = nsecs.count(); + to->clock_type = GPR_CLOCK_REALTIME; } void TimepointHR2Timespec(const high_resolution_clock::time_point& from, @@ -74,6 +75,7 @@ void TimepointHR2Timespec(const high_resolution_clock::time_point& from, nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs); to->tv_sec = secs.count(); to->tv_nsec = nsecs.count(); + to->clock_type = GPR_CLOCK_REALTIME; } system_clock::time_point Timespec2Timepoint(gpr_timespec t) { diff --git a/src/node/ext/completion_queue_async_worker.cc b/src/node/ext/completion_queue_async_worker.cc index 4be208c82d..1215c97e19 100644 --- a/src/node/ext/completion_queue_async_worker.cc +++ b/src/node/ext/completion_queue_async_worker.cc @@ -62,7 +62,8 @@ CompletionQueueAsyncWorker::CompletionQueueAsyncWorker() CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {} void CompletionQueueAsyncWorker::Execute() { - result = grpc_completion_queue_next(queue, gpr_inf_future); + result = + grpc_completion_queue_next(queue, gpr_inf_future(GPR_CLOCK_REALTIME)); if (!result.success) { SetErrorMessage("The batch encountered an error"); } diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc index 51c55ba965..34cde9ffab 100644 --- a/src/node/ext/server.cc +++ b/src/node/ext/server.cc @@ -161,7 +161,8 @@ void Server::ShutdownServer() { grpc_server_shutdown_and_notify(this->wrapped_server, this->shutdown_queue, NULL); - grpc_completion_queue_pluck(this->shutdown_queue, NULL, gpr_inf_future); + grpc_completion_queue_pluck(this->shutdown_queue, NULL, + gpr_inf_future(GPR_CLOCK_REALTIME)); this->wrapped_server = NULL; } } diff --git a/src/node/ext/timeval.cc b/src/node/ext/timeval.cc index bc3237f7a6..e3620fc91d 100644 --- a/src/node/ext/timeval.cc +++ b/src/node/ext/timeval.cc @@ -42,18 +42,18 @@ namespace node { gpr_timespec MillisecondsToTimespec(double millis) { if (millis == std::numeric_limits<double>::infinity()) { - return gpr_inf_future; + return gpr_inf_future(GPR_CLOCK_REALTIME); } else if (millis == -std::numeric_limits<double>::infinity()) { - return gpr_inf_past; + return gpr_inf_past(GPR_CLOCK_REALTIME); } else { return gpr_time_from_micros(static_cast<int64_t>(millis * 1000)); } } double TimespecToMilliseconds(gpr_timespec timespec) { - if (gpr_time_cmp(timespec, gpr_inf_future) == 0) { + if (gpr_time_cmp(timespec, gpr_inf_future(GPR_CLOCK_REALTIME)) == 0) { return std::numeric_limits<double>::infinity(); - } else if (gpr_time_cmp(timespec, gpr_inf_past) == 0) { + } else if (gpr_time_cmp(timespec, gpr_inf_past(GPR_CLOCK_REALTIME)) == 0) { return -std::numeric_limits<double>::infinity(); } else { return (static_cast<double>(timespec.tv_sec) * 1000 + diff --git a/src/python/src/grpc/_adapter/_c/utility.c b/src/python/src/grpc/_adapter/_c/utility.c index b82b042268..000c8d0c38 100644 --- a/src/python/src/grpc/_adapter/_c/utility.c +++ b/src/python/src/grpc/_adapter/_c/utility.c @@ -390,6 +390,7 @@ gpr_timespec pygrpc_cast_double_to_gpr_timespec(double seconds) { } else { result.tv_sec = (time_t)seconds; result.tv_nsec = ((seconds - result.tv_sec) * 1e9); + result.clock_type = GPR_CLOCK_REALTIME; } return result; } diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 706a2a75c2..b0ecbce091 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -222,24 +222,31 @@ static VALUE grpc_rb_time_val_to_s(VALUE self) { return rb_funcall(grpc_rb_time_val_to_time(self), id_to_s, 0); } +static gpr_timespec zero_realtime; +static gpr_timespec inf_future_realtime; +static gpr_timespec inf_past_realtime; + /* Adds a module with constants that map to gpr's static timeval structs. */ static void Init_grpc_time_consts() { VALUE grpc_rb_mTimeConsts = rb_define_module_under(grpc_rb_mGrpcCore, "TimeConsts"); grpc_rb_cTimeVal = rb_define_class_under(grpc_rb_mGrpcCore, "TimeSpec", rb_cObject); + zero_realtime = gpr_time_0(GPR_CLOCK_REALTIME); + inf_future_realtime = gpr_inf_future(GPR_CLOCK_REALTIME); + inf_past_realtime = gpr_inf_past(GPR_CLOCK_REALTIME); rb_define_const( grpc_rb_mTimeConsts, "ZERO", TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type, - (void *)&gpr_time_0)); + (void *)&zero_realtime)); rb_define_const( grpc_rb_mTimeConsts, "INFINITE_FUTURE", TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type, - (void *)&gpr_inf_future(GPR_CLOCK_REALTIME))); + (void *)&inf_future_realtime)); rb_define_const( grpc_rb_mTimeConsts, "INFINITE_PAST", TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type, - (void *)&gpr_inf_past(GPR_CLOCK_REALTIME))); + (void *)&inf_past_realtime)); rb_define_method(grpc_rb_cTimeVal, "to_time", grpc_rb_time_val_to_time, 0); rb_define_method(grpc_rb_cTimeVal, "inspect", grpc_rb_time_val_inspect, 0); rb_define_method(grpc_rb_cTimeVal, "to_s", grpc_rb_time_val_to_s, 0); |