Class: UnifiedQueues::Single::Driver::PoorPriorityQueueDriver
- Inherits:
-
UnifiedQueues::Single::Driver
- Object
- UnifiedQueues::Single::Driver
- UnifiedQueues::Single::Driver::PoorPriorityQueueDriver
- Defined in:
- lib/unified-queues/single/driver/priority_queue.rb
Overview
Minimal priority queue driver. Uses the PoorPriorityQueue
class from PriorityQueue
gem. Priority is supported.
It isn’t implement equivalent of the #clear
method, so it falls backs to naive “popping” style clearing.
Also note, it’s very minimalistic implementation, so both calls to PoorPriorityQueue#length and PoorPriorityQueue#empty? will throw an exception.
Instance Attribute Summary
Attributes inherited from UnifiedQueues::Single::Driver
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Indicates queue is empty.
-
#length ⇒ Integer
Returns length of the queue.
-
#pop(blocking = false) ⇒ Object
Pops value out of the queue.
-
#push(value, key = value) ⇒ Object
Pushes the value into the queue.
Methods inherited from UnifiedQueues::Single::Driver
#clear!, #evented?, #initialize, #linear?, #type
Constructor Details
This class inherits a constructor from UnifiedQueues::Single::Driver
Instance Method Details
#empty? ⇒ Boolean
Indicates queue is empty. Note, it isn’t implemented in this implementation.
134 135 136 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 134 def empty? not_implemented end |
#length ⇒ Integer
Returns length of the queue. Note, it isn’t implemented in this implementation.
145 146 147 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 145 def length not_implemented end |
#pop(blocking = false) ⇒ Object
Pops value out of the queue. Note, value with minimal priority will be popped out. Blocking isn’t supported.
123 124 125 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 123 def pop(blocking = false) @native.delete_min_return_key end |
#push(value, key = value) ⇒ Object
Pushes the value into the queue. Priority is supported.
111 112 113 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 111 def push(value, key = value) @native.push(value, key) end |