Class: TigerBeetle::AtomicCounter
- Inherits:
-
Object
- Object
- TigerBeetle::AtomicCounter
- Defined in:
- lib/tigerbeetle/atomic_counter.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #increment ⇒ Object
-
#initialize(value = 0) ⇒ AtomicCounter
constructor
A new instance of AtomicCounter.
Constructor Details
#initialize(value = 0) ⇒ AtomicCounter
Returns a new instance of AtomicCounter.
5 6 7 8 |
# File 'lib/tigerbeetle/atomic_counter.rb', line 5 def initialize(value = 0) @value = value @mutex = Mutex.new end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/tigerbeetle/atomic_counter.rb', line 3 def value @value end |
Instance Method Details
#increment ⇒ Object
10 11 12 |
# File 'lib/tigerbeetle/atomic_counter.rb', line 10 def increment @mutex.synchronize { @value += 1 } end |