class Gracefully::MutexBasedSynchronizedCounter

The counter equipped with the possibly easiest kind of synchronization.

Public Class Methods

new(counter) click to toggle source

@param [Counter] counter

# File lib/gracefully/mutex_based_synchronized_counter.rb, line 9
def initialize(counter)
  @counter = counter
  @mutex = Mutex.new
end

Public Instance Methods

count() click to toggle source
# File lib/gracefully/mutex_based_synchronized_counter.rb, line 26
def count
  @counter.count
end
increment!() click to toggle source
# File lib/gracefully/mutex_based_synchronized_counter.rb, line 20
def increment!
  @mutex.synchronize do
    @counter.increment!
  end
end
reset!() click to toggle source
# File lib/gracefully/mutex_based_synchronized_counter.rb, line 14
def reset!
  @mutex.synchronize do
    @counter.reset!
  end
end