Exemple #1
0
/* Closes the channel, calling it's destroy method */
static VALUE grpc_rb_channel_destroy(VALUE self) {
  grpc_rb_channel *wrapper = NULL;
  grpc_channel *ch = NULL;

  TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
  ch = wrapper->wrapped;
  if (ch != NULL) {
    grpc_rb_channel_safe_destroy(wrapper);
    wrapper->wrapped = NULL;
  }

  return Qnil;
}
Exemple #2
0
/* Destroys Channel instances. */
static void grpc_rb_channel_free(void* p) {
  grpc_rb_channel* ch = NULL;
  if (p == NULL) {
    return;
  };
  ch = (grpc_rb_channel*)p;

  if (ch->bg_wrapped != NULL) {
    /* assumption made here: it's ok to directly gpr_mu_lock the global
     * connection polling mutex becuse we're in a finalizer,
     * and we can count on this thread to not be interrupted or
     * yield the gil. */
    grpc_rb_channel_safe_destroy(ch->bg_wrapped);
    ch->bg_wrapped = NULL;
  }

  xfree(p);
}
Exemple #3
0
/* Destroys Channel instances. */
static void grpc_rb_channel_free(void *p) {
  grpc_rb_channel *ch = NULL;
  if (p == NULL) {
    return;
  };
  ch = (grpc_rb_channel *)p;

  if (ch->wrapped != NULL) {
    grpc_rb_channel_safe_destroy(ch);
    ch->wrapped = NULL;
  }

  if (ch->mu_init_done) {
    gpr_mu_destroy(&ch->channel_mu);
    gpr_cv_destroy(&ch->channel_cv);
  }

  xfree(p);
}
Exemple #4
0
static void* channel_safe_destroy_without_gil(void* arg) {
  grpc_rb_channel_safe_destroy((bg_watched_channel*)arg);
  return NULL;
}