End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
ConditionVariable#wait
wait(mutex, timeout=nil)
thread_sync.c
View on GitHub ↗
static VALUE
rb_condvar_wait(int argc, VALUE *argv, VALUE self)
{
rb_execution_context_t *ec = GET_EC();
struct rb_condvar *cv = condvar_ptr(self);
struct sleep_call args;
rb_scan_args(argc, argv, "11", &args.mutex, &args.timeout);
COROUTINE_STACK_LOCAL(struct sync_waiter, w);
w->self = args.mutex;
w->th = ec->thread_ptr;
w->fiber = ec->fiber_ptr;
list_add_tail(&cv->waitq, &w->node);
rb_ensure(do_sleep, (VALUE)&args, delete_from_waitq, (VALUE)w);
return self;
}
Releases the lock held in mutex and waits; reacquires the lock on wakeup.
If timeout is given, this method returns after timeout seconds passed, even if no other thread doesn’t signal.
Ruby version changes
-
3.0
-
ConditionVariable#waitmay now invoke theblock/unblockscheduler hooks in a non-blocking context. [Feature #16786]
-