Method: Polyphony::Queue#unshift
- Defined in:
- ext/polyphony/queue.c
#unshift(value) ⇒ Queue
Adds the given value to the queue's beginning. If the queue is capped and full, the call will block until a value is removed from the queue.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'ext/polyphony/queue.c', line 159
VALUE Queue_unshift(VALUE self, VALUE value) {
Queue_t *queue;
GetQueue(self, queue);
if (queue->closed)
rb_raise(cClosedQueueError, "queue closed");
if (queue->capacity) capped_queue_block_push(queue);
queue_schedule_first_blocked_fiber(&queue->shift_queue);
ring_buffer_unshift(&queue->values, value);
return self;
}
|