Sha256: 2d9be209aa017183d510e0b8b84305a23dc866ff840de09cd782223217186b7c

Contents?: true

Size: 777 Bytes

Versions: 6

Compression:

Stored size: 777 Bytes

Contents

# Queue that stores all the Jobs waiting to be processed or fully processed

module RestFtpDaemon
  class Counters

    # Class options
    attr_reader :stats

    def initialize
      @stats = {}
      @mutex_stats = Mutex.new
    end

    def set group, name, value
      @mutex_stats.synchronize do
        @stats[group] ||= {}
        @stats[group][name] = value
      end
    end

    def get group, name
      @mutex_stats.synchronize do
        @stats[group][name] if @stats[group].is_a? Hash
      end
    end

    def add group, name, value
      @mutex_stats.synchronize do
        @stats[group] ||= {}
        @stats[group][name] ||= 0
        @stats[group][name] += value
      end
    end

    def increment group, name
      add group, name, 1
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.306.4 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.306.3 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.306.1 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.306.0 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.305.0 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.304.0 lib/rest-ftp-daemon/counters.rb