push(*args)
public
Pushes object to the queue.
If there is no space left in the queue, waits until space becomes
available, unless non_block is true. If non_block is
true, the thread isn’t suspended, and ThreadError is raised.
Show source
static VALUE
rb_szqueue_push(int argc, VALUE *argv, VALUE self)
{
struct waiting_delete args;
int should_block = szqueue_push_should_block(argc, argv);
args.waiting = GET_SZQUEUE_WAITERS(self);
args.th = rb_thread_current();
while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
if (!should_block) {
rb_raise(rb_eThreadError, "queue full");
}
else if (queue_closed_p(self)) {
goto closed;
}
else {
rb_ary_push(args.waiting, args.th);
rb_ensure(queue_sleep, Qfalse, queue_delete_from_waiting, (VALUE)&args);
}
}
if (queue_closed_p(self)) {
closed:
raise_closed_queue_error(self);
}
return queue_do_push(self, argv[0]);
}