Class: Sidekiq::Metrics::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/metrics/shared.rb

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



6
7
8
9
# File 'lib/sidekiq/metrics/shared.rb', line 6

def initialize
  @value = 0
  @lock = Mutex.new
end

Instance Method Details

#incrementObject



11
12
13
# File 'lib/sidekiq/metrics/shared.rb', line 11

def increment
  @lock.synchronize { @value += 1 }
end

#valueObject



15
16
17
# File 'lib/sidekiq/metrics/shared.rb', line 15

def value
  @lock.synchronize { @value }
end