Class: UnifiedQueues::Single::Driver Abstract
- Inherits:
-
Object
- Object
- UnifiedQueues::Single::Driver
- Defined in:
- lib/unified-queues/single/driver.rb,
lib/unified-queues/single/driver/depq.rb,
lib/unified-queues/single/driver/array.rb,
lib/unified-queues/single/driver/queue.rb,
lib/unified-queues/single/driver/algorithms.rb,
lib/unified-queues/single/driver/evented-queue.rb,
lib/unified-queues/single/driver/priority_queue.rb
Overview
Abstract single driver class.
Direct Known Subclasses
ArrayDriver, CPriorityQueueDriver, ContainersDriver::Heap, DepqDriver, EventedQueueDriver, PoorPriorityQueueDriver, QueueDriver, RubyPriorityQueueDriver
Defined Under Namespace
Modules: ContainersDriver Classes: ArrayDriver, CPriorityQueueDriver, DepqDriver, EventedQueueDriver, PoorPriorityQueueDriver, QueueDriver, RubyPriorityQueueDriver
Instance Attribute Summary collapse
-
#native ⇒ Object
Holds native object.
Instance Method Summary collapse
-
#clear!(&block) ⇒ Object
(also: #clear)
abstract
Clears the queue.
-
#empty?(&block) ⇒ Boolean
abstract
Indicates queue is empty.
-
#evented? ⇒ Boolean
Indicates, driver is evented so expexts callbacks.
-
#initialize(cls, *args, &block) ⇒ Driver
constructor
Constructor.
-
#length(&block) ⇒ Integer
(also: #size)
abstract
Returns length of the queue.
-
#linear? ⇒ Boolean
Indicates, driver is evented so expexts callbacks.
-
#pop(blocking = false, &block) ⇒ Object
abstract
Pops value out of the queue.
-
#push(value, key = value, &block) ⇒ Object
(also: #<<)
abstract
Pushes the value into the queue.
-
#type ⇒ :linear, :evented
abstract
Returs type of the queue.
Constructor Details
#initialize(cls, *args, &block) ⇒ Driver
Constructor.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/unified-queues/single/driver.rb', line 38 def initialize(cls, *args, &block) if self.instance_of? UnifiedQueues::Single::Driver not_implemented end if cls.kind_of? Class @native = cls::new(*args, &block) else @native = cls end end |
Instance Attribute Details
#native ⇒ Object
Holds native object.
31 32 33 |
# File 'lib/unified-queues/single/driver.rb', line 31 def native @native end |
Instance Method Details
#clear!(&block) ⇒ Object Also known as: clear
Clears the queue.
92 93 94 95 |
# File 'lib/unified-queues/single/driver.rb', line 92 def clear!(&block) while not self.pop.nil? end end |
#empty?(&block) ⇒ Boolean
Indicates queue is empty.
83 84 85 |
# File 'lib/unified-queues/single/driver.rb', line 83 def empty?(&block) not_implemented end |
#evented? ⇒ Boolean
Indicates, driver is evented so expexts callbacks.
130 131 132 |
# File 'lib/unified-queues/single/driver.rb', line 130 def evented? self.type == :evented end |
#length(&block) ⇒ Integer Also known as: size
Returns length of the queue.
106 107 108 |
# File 'lib/unified-queues/single/driver.rb', line 106 def length(&block) not_implemented end |
#linear? ⇒ Boolean
Indicates, driver is evented so expexts callbacks.
139 140 141 |
# File 'lib/unified-queues/single/driver.rb', line 139 def linear? self.type == :linear end |
#pop(blocking = false, &block) ⇒ Object
Pops value out of the queue.
72 73 74 |
# File 'lib/unified-queues/single/driver.rb', line 72 def pop(blocking = false, &block) not_implemented end |
#push(value, key = value, &block) ⇒ Object Also known as: <<
Pushes the value into the queue.
58 59 60 |
# File 'lib/unified-queues/single/driver.rb', line 58 def push(value, key = value, &block) not_implemented end |
#type ⇒ :linear, :evented
Returs type of the queue. Queue can be :linear
which means, calls values are returned using return
or :evented
which indicates necessity of callbacks.
121 122 123 |
# File 'lib/unified-queues/single/driver.rb', line 121 def type not_implemented end |