class Sqreen::CappedQueue

A simple size limited queue. When trying to enqueue more than the capacity the older elements will get thrown

Attributes

capacity[R]

Public Class Methods

new(capacity) click to toggle source
Calls superclass method
# File lib/sqreen/capped_queue.rb, line 15
def initialize(capacity)
  @capacity = capacity
  super()
end

Public Instance Methods

original_push(value)
Alias for: push
push(value) click to toggle source
# File lib/sqreen/capped_queue.rb, line 22
def push(value)
  until size < @capacity
    discarded = pop
    Sqreen.log.debug { "Discarded from queue: #{discarded}" }
  end
  Sqreen.log.debug { "Pushed to the queue: #{value}" }
  original_push(value)
end
Also aliased as: original_push