Distributed/shared store-wide semaphore
@example Use `Moneta::Semaphore`
semaphore = Moneta::Semaphore.new(store, 'semaphore', 2) semaphore.synchronize do # Synchronized access # ... end
@api public
@param [Moneta store] store The store we want to lock @param [Object] counter Key of the counter entry @param [Fixnum] max Maximum number of threads which are allowed to enter the critical section
# File lib/moneta/synchronize.rb, line 106 def initialize(store, counter, max = 1) raise 'Store must support feature :increment' unless store.supports?(:increment) @store, @counter, @max = store, counter, max @store.increment(@counter, 0, :expires => false) # Ensure that counter exists end
Generated with the Darkfish Rdoc Generator 2.