Sha256: 58e779ec80eac508679f0516278a81ddd046f9137898e8ce48e78de799d4e574

Contents?: true

Size: 559 Bytes

Versions: 8

Compression:

Stored size: 559 Bytes

Contents

module Metriksd
  class Timeslice
    attr_reader :time

    def initialize(time)
      @time    = time
      @mutex   = Mutex.new
      @dirty   = false
      @records = {}
    end
    
    def dirty?
      @mutex.synchronize do
        @dirty
      end
    end

    def flush
      @mutex.synchronize do
        @dirty = false
        @records.values
      end
    end
    
    def push(data)
      @mutex.synchronize do
        @records["#{data.client_id}/#{data.name}"] = data
        @dirty = true
      end
    end
    alias_method :<<, :push
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metriksd-0.5.7 lib/metriksd/timeslice.rb
metriksd-0.5.6 lib/metriksd/timeslice.rb
metriksd-0.5.5 lib/metriksd/timeslice.rb
metriksd-0.5.4 lib/metriksd/timeslice.rb
metriksd-0.5.3 lib/metriksd/timeslice.rb
metriksd-0.5.2 lib/metriksd/timeslice.rb
metriksd-0.5.1 lib/metriksd/timeslice.rb
metriksd-0.5.0 lib/metriksd/timeslice.rb