aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/ext/grpc/rb_grpc.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-07-13 09:16:03 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-07-13 09:16:03 -0700
commit354398f9f5191bb44198b94e1828eafb60de5a67 (patch)
tree716e16fa3c813b5b02344eba8e341c27fd40840c /src/ruby/ext/grpc/rb_grpc.c
parent75cfb044f3c5582a50582c375b443ee4ab029c33 (diff)
Updating wrapped languages to new time functions
Diffstat (limited to 'src/ruby/ext/grpc/rb_grpc.c')
-rw-r--r--src/ruby/ext/grpc/rb_grpc.c13
1 files changed, 10 insertions, 3 deletions
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);