Class: UnifiedQueues::Single::Driver Abstract

Inherits:
Object
  • Object
show all
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

This class is abstract.

Abstract single driver class.

Defined Under Namespace

Modules: ContainersDriver Classes: ArrayDriver, CPriorityQueueDriver, DepqDriver, EventedQueueDriver, PoorPriorityQueueDriver, QueueDriver, RubyPriorityQueueDriver

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nativeObject

Holds native object.

Returns:

  • (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

This method is abstract.

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

This method is abstract.

Indicates queue is empty.

Parameters:

  • +true+ (Boolean)

    if it’s, false otherwise

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)

    true if it is, false otherwise



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

This method is abstract.

Returns length of the queue.

Returns:

  • (Integer)


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.

Returns:

  • (Boolean)

    true if it is, false otherwise



139
140
141
# File 'lib/unified-queues/single/driver.rb', line 139

def linear?
    self.type == :linear
end

#pop(blocking = false, &block) ⇒ Object

This method is abstract.

Pops value out of the queue.

Parameters:

  • blocking (Boolean|Integer) (defaults to: false)

    true or timeout if it should block, false otherwise

  • queue (Object)

    value



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: <<

This method is abstract.

Pushes the value into the queue.

Parameters:

  • value (Object)

    value for push

  • key (Object) (defaults to: value)

    key for priority queues



58
59
60
# File 'lib/unified-queues/single/driver.rb', line 58

def push(value, key = value, &block)
    not_implemented
end

#type:linear, :evented

This method is abstract.

Returs type of the queue. Queue can be :linear which means, calls values are returned using return or :evented which indicates necessity of callbacks.

Returns:

  • (:linear, :evented)


121
122
123
# File 'lib/unified-queues/single/driver.rb', line 121

def type
    not_implemented
end