Files

Class/Module Index [+]

Quicksearch

Moneta::Mutex

Distributed/shared store-wide mutex

@example Use `Moneta::Mutex`

mutex = Moneta::Mutex.new(store, 'mutex')
mutex.synchronize do
  # Synchronized access
  store['counter'] += 1
end

@api public

Public Class Methods

new(store, lock) click to toggle source

@param [Moneta store] store The store we want to lock @param [Object] lock Key of the lock entry

# File lib/moneta/synchronize.rb, line 76
def initialize(store, lock)
  raise 'Store must support feature :create' unless store.supports?(:create)
  @store, @lock = store, lock
end

Protected Instance Methods

enter_primitive() click to toggle source
# File lib/moneta/synchronize.rb, line 83
def enter_primitive
  @store.create(@lock, '', :expires => false)
end
leave_primitive() click to toggle source
# File lib/moneta/synchronize.rb, line 87
def leave_primitive
  @store.delete(@lock)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.