static VALUE dnssd_service_stop(VALUE self) { VALUE thread; DNSServiceRef *client; get(cDNSSDService, self, DNSServiceRef, client); RDATA(self)->data = NULL; if (client == NULL) rb_raise(eDNSSDError, "service is already stopped"); thread = rb_ivar_get(self, dnssd_iv_thread); rb_ivar_set(self, dnssd_iv_continue, Qfalse); if (!NIL_P(thread) && thread != rb_thread_current()) { rb_thread_run(thread); rb_funcall(thread, dnssd_id_join, 0); } dnssd_service_free_client(client); rb_ivar_set(self, dnssd_iv_type, Qnil); return self; }
static void cleanup(debug_context_t *dc) { VALUE thread; dc->stop_reason = CTX_STOP_NONE; /* checks for dead threads */ check_threads_table(); /* release a lock */ locker = Qnil; /* let the next thread to run */ thread = remove_from_locked(); if (thread != Qnil) rb_thread_run(thread); }
/* * Releases our global lock and passes execution on to another thread, either * the thread specified by +next_thread+ or any other thread if +next_thread+ * is nil. */ void release_lock(void) { VALUE thread; cleanup_dead_threads(); locker = Qnil; if (NIL_P(next_thread)) thread = pop_from_locked(); else { remove_from_locked(next_thread); thread = next_thread; next_thread = Qnil; } if (!NIL_P(thread) && is_living_thread(thread)) rb_thread_run(thread); }