Method: Polyphony::Queue#close
- Defined in:
- ext/polyphony/queue.c
#close ⇒ Queue
Marks the queue as closed. Any fibers currently waiting on the queue are
resumed with a nil value. After the queue is closed, trying to remove items
from the queue will cause a ClosedQueueError to be raised.
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'ext/polyphony/queue.c', line 440
VALUE Queue_close(VALUE self) {
Queue_t *queue;
GetQueue(self, queue);
if (queue->closed) goto end;
queue->closed = 1;
// release all fibers waiting on `#shift`
while (queue->shift_queue.count) {
VALUE fiber = ring_buffer_shift(&queue->shift_queue);
if (fiber == Qnil) break;
Fiber_make_runnable(fiber, Qnil);
}
end:
return self;
}
|