Method: Polyphony::Queue#initialize
- Defined in:
- ext/polyphony/queue.c
#new ⇒ Object #new(capacity) ⇒ Object
Initializes a queue instance. If the capacity is given, the queue becomes capped, i.e. it cannot contain more elements than its capacity. When trying to add items to a capped queue that is full, the current fiber will block until at least one item is removed from the queue.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'ext/polyphony/queue.c', line 74 static VALUE Queue_initialize(int argc, VALUE *argv, VALUE self) { Queue_t *queue; GetQueue(self, queue); queue->closed = 0; ring_buffer_init(&queue->values); ring_buffer_init(&queue->shift_queue); ring_buffer_init(&queue->push_queue); queue->capacity = (argc == 1) ? NUM2UINT(argv[0]) : 0; return self; } |