static void signal_condvar(ConditionVariable *condvar) { VALUE waking = thread_exclusive(wake_one, (VALUE)&condvar->waiting); if (RTEST(waking)) { run_thread(waking); } }
static VALUE rb_condvar_broadcast(VALUE self) { ConditionVariable *condvar; Data_Get_Struct(self, ConditionVariable, condvar); thread_exclusive(wake_all, (VALUE)&condvar->waiting); rb_thread_schedule(); return self; }
static VALUE unlock_mutex(Mutex *mutex) { VALUE waking = thread_exclusive(unlock_mutex_inner, (VALUE)mutex); if (!RTEST(waking)) { return Qfalse; } run_thread(waking); return Qtrue; }
static VALUE rb_mutex_exclusive_unlock(VALUE self) { Mutex *mutex; VALUE waking; Data_Get_Struct(self, Mutex, mutex); waking = thread_exclusive(rb_mutex_exclusive_unlock_inner, (VALUE)mutex); if (!RTEST(waking)) { return Qnil; } run_thread(waking); return self; }
static VALUE rb_thread_exclusive(void) { return thread_exclusive(rb_yield, Qundef); }