void Init_grpc_c() { if (!grpc_rb_load_core()) { rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core"); return; } rb_global_variable(&bg_thread_init_rb_mu); bg_thread_init_rb_mu = rb_mutex_new(); grpc_rb_mGRPC = rb_define_module("GRPC"); grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); grpc_rb_sNewServerRpc = rb_struct_define( "NewServerRpc", "method", "host", "deadline", "metadata", "call", NULL); grpc_rb_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL); sym_code = ID2SYM(rb_intern("code")); sym_details = ID2SYM(rb_intern("details")); sym_metadata = ID2SYM(rb_intern("metadata")); Init_grpc_channel(); Init_grpc_call(); Init_grpc_call_credentials(); Init_grpc_channel_credentials(); Init_grpc_server(); Init_grpc_server_credentials(); Init_grpc_status_codes(); Init_grpc_time_consts(); Init_grpc_compression_options(); }
void Init_grpc() { grpc_init(); /* TODO: find alternative to ruby_vm_at_exit that is ok in Ruby 2.0 */ #ifdef RUBY_TYPED_FREE_IMMEDIATELY ruby_vm_at_exit(grpc_rb_shutdown); #endif grpc_rb_mGRPC = rb_define_module("GRPC"); grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); grpc_rb_sNewServerRpc = rb_struct_define("NewServerRpc", "method", "host", "deadline", "metadata", "call", NULL); grpc_rb_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL); sym_code = ID2SYM(rb_intern("code")); sym_details = ID2SYM(rb_intern("details")); sym_metadata = ID2SYM(rb_intern("metadata")); Init_grpc_channel(); Init_grpc_completion_queue(); Init_grpc_call(); Init_grpc_call_credentials(); Init_grpc_channel_credentials(); Init_grpc_server(); Init_grpc_server_credentials(); Init_grpc_status_codes(); Init_grpc_time_consts(); }
void Init_grpc() { grpc_init(); ruby_vm_at_exit(grpc_rb_shutdown); rb_mGRPC = rb_define_module("GRPC"); rb_mGrpcCore = rb_define_module_under(rb_mGRPC, "Core"); rb_sNewServerRpc = rb_struct_define("NewServerRpc", "method", "host", "deadline", "metadata", NULL); rb_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL); Init_grpc_byte_buffer(); Init_grpc_event(); Init_grpc_channel(); Init_grpc_completion_queue(); Init_grpc_call(); Init_grpc_credentials(); Init_grpc_metadata(); Init_grpc_server(); Init_grpc_server_credentials(); Init_grpc_status_codes(); Init_grpc_time_consts(); }
void Init_grpc_c() { if (!grpc_rb_load_core()) { rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core"); return; } /* ruby_vm_at_exit doesn't seem to be working. It would crash once every * blue moon, and some users are getting it repeatedly. See the discussions * - https://github.com/grpc/grpc/pull/5337 * - https://bugs.ruby-lang.org/issues/12095 * * In order to still be able to handle the (unlikely) situation where the * extension is loaded by a first Ruby VM that is subsequently destroyed, * then loaded again by another VM within the same process, we need to * schedule our initialization and destruction only once. */ gpr_once_init(&g_once_init, grpc_ruby_once_init); grpc_rb_mGRPC = rb_define_module("GRPC"); grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); grpc_rb_sNewServerRpc = rb_struct_define("NewServerRpc", "method", "host", "deadline", "metadata", "call", NULL); grpc_rb_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL); sym_code = ID2SYM(rb_intern("code")); sym_details = ID2SYM(rb_intern("details")); sym_metadata = ID2SYM(rb_intern("metadata")); Init_grpc_channel(); Init_grpc_call(); Init_grpc_call_credentials(); Init_grpc_channel_credentials(); Init_grpc_server(); Init_grpc_server_credentials(); Init_grpc_status_codes(); Init_grpc_time_consts(); Init_grpc_compression_options(); }