Class: Clarion::Counters::Memory
- Defined in:
- lib/clarion/counters/memory.rb
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #store(key) ⇒ Object
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
7 8 9 10 11 |
# File 'lib/clarion/counters/memory.rb', line 7 def initialize(*) super @lock = Mutex.new @counters = {} end |
Instance Method Details
#get(key) ⇒ Object
13 14 15 16 17 |
# File 'lib/clarion/counters/memory.rb', line 13 def get(key) @lock.synchronize do @counters[key.handle] end end |
#store(key) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/clarion/counters/memory.rb', line 19 def store(key) @lock.synchronize do counter = @counters[key.handle] if !counter || key.counter > counter @counters[key.handle] = key.counter end end end |