Sha256: e240c21cda7c881be92238a2d05f4ca588b5ec5935401c8b68b0b56a0863120b
Contents?: true
Size: 727 Bytes
Versions: 10
Compression:
Stored size: 727 Bytes
Contents
# typed: ignore # Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.com/terms.html require 'sqreen/log' module Sqreen # A simple size limited queue. # When trying to enqueue more than the capacity # the older elements will get thrown class CappedQueue < Queue attr_reader :capacity def initialize(capacity) @capacity = capacity super() end alias original_push push 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 end end
Version data entries
10 entries across 10 versions & 1 rubygems