Method: Polyphony::Queue#shift

Defined in:
ext/polyphony/queue.c

#shiftany #shift(true) ⇒ any #popany #pop(true) ⇒ any #deqany #deq(true) ⇒ any

Removes the first value in the queue and returns it. If the optional nonblock parameter is true, the operation is non-blocking. In non-blocking mode, if the queue is empty, a ThreadError exception is raised. In blocking mode, if the queue is empty, the call will block until an item is added to the queue.

Parameters:

  • non-blocking mode

Returns:

  • first value in queue



232
233
234
235
236
237
238
239
240
# File 'ext/polyphony/queue.c', line 232

VALUE Queue_shift(int argc,VALUE *argv, VALUE self) {
  int nonblock = argc && RTEST(argv[0]);
  Queue_t *queue;
  GetQueue(self, queue);

  return nonblock ?
    Queue_shift_nonblock(queue) :
    Queue_shift_block(queue);
}