Go to the documentation of this file.
19 #include <ruby/ruby.h>
27 #include <sys/types.h>
57 #ifdef RUBY_TYPED_FREE_IMMEDIATELY
58 RUBY_TYPED_FREE_IMMEDIATELY
65 rb_raise(rb_eTypeError,
66 "allocation of %s only allowed from the gRPC native layer",
73 rb_raise(rb_eTypeError,
74 "initialization of %s only allowed from the gRPC native layer",
75 rb_obj_classname(
self));
82 rb_raise(rb_eTypeError,
"Copy initialization of %s is not supported",
83 rb_obj_classname(
copy));
101 const char* tstr = interval ?
"time interval" :
"time";
102 const char* want =
" want <secs from epoch>|<Time>|<GRPC::TimeConst.*>";
105 switch (
TYPE(time)) {
111 }
else if (CLASS_OF(time) == rb_cTime) {
112 t.tv_sec = NUM2INT(rb_funcall(time,
id_tv_sec, 0));
113 t.tv_nsec = NUM2INT(rb_funcall(time,
id_tv_nsec, 0));
115 rb_raise(rb_eTypeError,
"bad input: (%s)->c_timeval, got <%s>,%s", tstr,
116 rb_obj_classname(time), want);
121 t.tv_sec = FIX2LONG(time);
122 if (interval && t.tv_sec < 0)
123 rb_raise(rb_eArgError,
"%s must be positive", tstr);
128 if (interval && RFLOAT_VALUE(time) < 0.0)
129 rb_raise(rb_eArgError,
"%s must be positive", tstr);
133 d = modf(RFLOAT_VALUE(time), &
f);
140 rb_raise(rb_eRangeError,
"%f out of Time range", RFLOAT_VALUE(time));
142 t.tv_nsec = (
int)(
d * 1e9 + 0.5);
147 t.tv_sec = NUM2LONG(time);
148 if (interval && t.tv_sec < 0)
149 rb_raise(rb_eArgError,
"%s must be positive", tstr);
154 rb_raise(rb_eTypeError,
"bad input: (%s)->c_timeval, got <%s>,%s", tstr,
155 rb_obj_classname(time), want);
177 return rb_funcall(rb_cTime,
id_at, 2, INT2NUM(real_time.
tv_sec),
178 INT2NUM(real_time.
tv_nsec / 1000));
197 VALUE grpc_rb_mTimeConsts =
205 grpc_rb_mTimeConsts,
"ZERO",
209 grpc_rb_mTimeConsts,
"INFINITE_FUTURE",
213 grpc_rb_mTimeConsts,
"INFINITE_PAST",
219 id_at = rb_intern(
"at");
263 rb_raise(rb_eRuntimeError,
"grpc cannot be used before and after forking");
292 "GRPC_RUBY: grpc_ruby_init - prev g_grpc_ruby_init_count:%" PRId64,
301 "GRPC_RUBY: grpc_ruby_shutdown - prev g_grpc_ruby_init_count:%" PRId64,
307 rb_raise(rb_eLoadError,
"Couldn't find or load gRPC's dynamic C core");
317 "NewServerRpc",
"method",
"host",
"deadline",
"metadata",
"call", NULL);
319 sym_code = ID2SYM(rb_intern(
"code"));
VALUE grpc_rb_cannot_alloc(VALUE cls)
#define GRPC_RB_MEMSIZE_UNAVAILABLE
static pid_t grpc_init_pid
void grpc_ruby_shutdown()
#define GRPC_RB_GC_NOT_MARKED
GPRAPI gpr_timespec gpr_time_0(gpr_clock_type type)
static int bg_thread_init_done
static rb_data_type_t grpc_rb_timespec_data_type
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
static VALUE grpc_rb_cTimeVal
GPRAPI void gpr_once_init(gpr_once *once, void(*init_function)(void))
void grpc_rb_event_queue_thread_start()
static VALUE grpc_rb_time_val_to_time(VALUE self)
static int64_t g_grpc_ruby_init_count
void grpc_rb_channel_polling_thread_start()
static gpr_timespec inf_past_realtime
static void grpc_ruby_set_init_pid(void)
static gpr_timespec inf_future_realtime
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
VALUE grpc_rb_sNewServerRpc
void Init_grpc_channel_credentials()
#define GRPC_RB_GC_DONT_FREE
static VALUE bg_thread_init_rb_mu
GPRAPI gpr_timespec gpr_inf_past(gpr_clock_type type)
static bool grpc_ruby_forked_after_init(void)
gpr_timespec grpc_rb_time_timeval(VALUE time, int interval)
GPRAPI gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type clock_type)
VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self)
void Init_grpc_xds_server_credentials()
static VALUE grpc_rb_time_val_to_s(VALUE self)
void Init_grpc_call_credentials()
VALUE grpc_rb_cannot_init(VALUE self)
void grpc_ruby_fork_guard()
static void grpc_ruby_init_threads()
void Init_grpc_xds_channel_credentials()
static void Init_grpc_time_consts()
void Init_grpc_server_credentials()
static gpr_once g_once_init
static VALUE grpc_rb_time_val_inspect(VALUE self)
GRPCAPI void grpc_init(void)
void Init_grpc_compression_options()
GRPCAPI void grpc_shutdown(void)
static gpr_timespec zero_realtime
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:59