Class: AsyncFutures::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/async_futures/counter.rb

Overview

Simple counter. Useful to wrap with a SynchronizedDelegator.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = 0) ⇒ Counter

Returns a new instance of Counter.



9
10
11
# File 'lib/async_futures/counter.rb', line 9

def initialize(value = 0)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/async_futures/counter.rb', line 7

def value
  @value
end

Instance Method Details

#increment(amount = 1) ⇒ Object



13
14
15
# File 'lib/async_futures/counter.rb', line 13

def increment(amount = 1)
  @value += amount
end