Class: Bob::BackgroundEngines::Threaded::ThreadPool::Incrementor
- Defined in:
- lib/bob/background_engines/threaded.rb
Instance Method Summary collapse
- #dec(v = 1) ⇒ Object
- #inc(v = 1) ⇒ Object
-
#initialize(v = 0) ⇒ Incrementor
constructor
A new instance of Incrementor.
- #inspect ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize(v = 0) ⇒ Incrementor
Returns a new instance of Incrementor.
25 26 27 28 |
# File 'lib/bob/background_engines/threaded.rb', line 25 def initialize(v = 0) @m = Mutex.new @v = v end |
Instance Method Details
#dec(v = 1) ⇒ Object
34 35 36 |
# File 'lib/bob/background_engines/threaded.rb', line 34 def dec(v = 1) sync { @v -= v } end |
#inc(v = 1) ⇒ Object
30 31 32 |
# File 'lib/bob/background_engines/threaded.rb', line 30 def inc(v = 1) sync { @v += v } end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/bob/background_engines/threaded.rb', line 38 def inspect @v.inspect end |
#to_i ⇒ Object
42 43 44 |
# File 'lib/bob/background_engines/threaded.rb', line 42 def to_i @v end |