Sha256: ac6af27a1076c646076c39452f28e6b30637d9edaf71578473ec36d9c1875c9d
Contents?: true
Size: 686 Bytes
Versions: 43
Compression:
Stored size: 686 Bytes
Contents
# Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.io/terms.html 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
43 entries across 43 versions & 1 rubygems