Class: UnifiedQueues::Single::Driver::QueueDriver
- Inherits:
-
UnifiedQueues::Single::Driver
- Object
- UnifiedQueues::Single::Driver
- UnifiedQueues::Single::Driver::QueueDriver
- Defined in:
- lib/unified-queues/single/driver/queue.rb
Overview
Queue queue driver. Uses standard library Queue
class for thread synchronized queueing. Priority isn’t supported.
Instance Attribute Summary
Attributes inherited from UnifiedQueues::Single::Driver
Instance Method Summary collapse
-
#clear! ⇒ Object
Clears the queue.
-
#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.
-
#type ⇒ :linear
Returs type of the queue.
Methods inherited from UnifiedQueues::Single::Driver
#evented?, #initialize, #linear?
Constructor Details
This class inherits a constructor from UnifiedQueues::Single::Driver
Instance Method Details
#clear! ⇒ Object
Clears the queue.
78 79 80 |
# File 'lib/unified-queues/single/driver/queue.rb', line 78 def clear! @native.clear end |
#empty? ⇒ Boolean
Indicates queue is empty.
70 71 72 |
# File 'lib/unified-queues/single/driver/queue.rb', line 70 def empty? @native.empty? end |
#length ⇒ Integer
Returns length of the queue.
87 88 89 |
# File 'lib/unified-queues/single/driver/queue.rb', line 87 def length @native.length end |
#pop(blocking = false) ⇒ Object
Pops value out of the queue.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/unified-queues/single/driver/queue.rb', line 51 def pop(blocking = false) if blocking.boolean? timeout = !blocking else timeout = blocking end begin @native.pop(blocking) rescue ThreadError nil end end |
#push(value, key = value) ⇒ Object
Pushes the value into the queue. Priority isn’t supported.
40 41 42 |
# File 'lib/unified-queues/single/driver/queue.rb', line 40 def push(value, key = value) @native.push(value) end |
#type ⇒ :linear
Returs type of the queue.
96 97 98 |
# File 'lib/unified-queues/single/driver/queue.rb', line 96 def type :linear end |