Class: Sidekiq::Metrics::Counter
- Inherits:
-
Object
- Object
- Sidekiq::Metrics::Counter
- Defined in:
- lib/sidekiq/metrics/shared.rb
Instance Method Summary collapse
- #increment ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #value ⇒ Object
Constructor Details
#initialize ⇒ Counter
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
#increment ⇒ Object
11 12 13 |
# File 'lib/sidekiq/metrics/shared.rb', line 11 def increment @lock.synchronize { @value += 1 } end |
#value ⇒ Object
15 16 17 |
# File 'lib/sidekiq/metrics/shared.rb', line 15 def value @lock.synchronize { @value } end |