Class: Ratomic::Counter
- Inherits:
-
Object
- Object
- Ratomic::Counter
- Defined in:
- lib/ratomic.rb
Overview
An atomic counter which can be incremented and decremented safely by multiple Ractors concurrently.
Instance Method Summary collapse
Instance Method Details
#dec(amt = 1) ⇒ Object
22 23 24 25 |
# File 'lib/ratomic.rb', line 22 def dec(amt = 1) raise ArgumentError, "amount must be positive: #{amt}" if amt < 0 decrement(amt) end |
#inc(amt = 1) ⇒ Object
17 18 19 20 |
# File 'lib/ratomic.rb', line 17 def inc(amt = 1) raise ArgumentError, "amount must be positive: #{amt}" if amt < 0 increment(amt) end |
#value ⇒ Object
13 14 15 |
# File 'lib/ratomic.rb', line 13 def value read end |