Sha256: 63ae1ab5dbb22b25c5866a879d0424310f821d814d5b8240da070ca28d43f595
Contents?: true
Size: 845 Bytes
Versions: 21
Compression:
Stored size: 845 Bytes
Contents
require 'singleton' # Queue that stores all the Jobs waiting to be processed or fully processed module RestFtpDaemon class Counters include Singleton def initialize # Initialize values @stats = {} # Create mutex @mutex = Mutex.new end def set group, name, value @mutex.synchronize do @stats[group] ||= {} @stats[group][name] = value end end def get group, name @mutex.synchronize do @stats[group][name] if @stats[group].is_a? Hash end end def add group, name, value @mutex.synchronize do @stats[group] ||= {} @stats[group][name] ||= 0 @stats[group][name] += value end end def increment group, name add group, name, 1 end def stats return @stats.dup end end end
Version data entries
21 entries across 21 versions & 1 rubygems