class EventedQueue::Recurring

Recurring evented queue implementation.

Attributes

scheduler[RW]

Holds scheduling routine. @return [Proc]

Public Class Methods

new(stack = UnifiedQueues::Single::new(Array), &scheduler) click to toggle source

Constructor. @param [Proc] &scheduler which indicates how to schedule recurring

Calls superclass method EventedQueue::new
# File lib/evented-queue/recurring.rb, line 25
def initialize(stack = UnifiedQueues::Single::new(Array), &scheduler)
    super(stack)
    @scheduler = scheduler
end

Public Instance Methods

pop(&block) click to toggle source

Pushes value out of the queue.

@return [Object] value from the queue @yield [Object] value from the queue

Calls superclass method EventedQueue#pop
# File lib/evented-queue/recurring.rb, line 37
def pop(&block)
    if self.empty?
        result = super(&block)
    else
        result = super(&block)
        
        if @scheduler.nil?
            self.pop(&block)
        else
            @scheduler.call(Proc::new { self.pop(&block) })
        end
    end
    
    return result
end