Class: UringMachine::Queue

Inherits:
Object
  • Object
show all
Defined in:
ext/um/um_queue_class.c,
ext/um/um_queue_class.c

Overview

A futex-based Queue implementation. The queue can be manipulated by calling ‘UringMachine#push`, `UringMachine#unshift`, `UringMachine#pop` and `UringMachine#shift`.

Instance Method Summary collapse

Constructor Details

#initializevoid

Initializes a new queue instance.



55
56
57
58
59
60
# File 'ext/um/um_queue_class.c', line 55

VALUE Queue_initialize(VALUE self) {
  struct um_queue *queue = Queue_data(self);
  RB_OBJ_WRITE(self, &queue->self, self);
  um_queue_init(queue);
  return self;
}

Instance Method Details

#countInteger

Returns the number of items in the queue.

Returns:

  • (Integer)

    number of items in the queue



66
67
68
69
# File 'ext/um/um_queue_class.c', line 66

VALUE Queue_count(VALUE self) {
  struct um_queue *queue = Queue_data(self);
  return UINT2NUM(queue->count);
}