Class: Moneta::Semaphore
- Inherits:
-
SynchronizePrimitive
- Object
- SynchronizePrimitive
- Moneta::Semaphore
- Defined in:
- lib/moneta/synchronize.rb
Overview
Distributed/shared store-wide semaphore
Instance Method Summary collapse
-
#initialize(store, counter, max = 1) ⇒ Semaphore
constructor
A new instance of Semaphore.
Methods inherited from SynchronizePrimitive
#enter, #leave, #locked?, #synchronize, #try_enter
Constructor Details
#initialize(store, counter, max = 1) ⇒ Semaphore
Returns a new instance of Semaphore.
99 100 101 102 103 |
# File 'lib/moneta/synchronize.rb', line 99 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 |