Class: WorkQueue::ThreadsafeCounter
- Inherits:
-
Object
- Object
- WorkQueue::ThreadsafeCounter
- Defined in:
- lib/workqueue.rb
Instance Method Summary collapse
- #incr(by = 1) ⇒ Object
-
#initialize(count = 0) ⇒ ThreadsafeCounter
constructor
A new instance of ThreadsafeCounter.
Constructor Details
#initialize(count = 0) ⇒ ThreadsafeCounter
Returns a new instance of ThreadsafeCounter.
5 6 7 |
# File 'lib/workqueue.rb', line 5 def initialize(count=0) @count = count end |
Instance Method Details
#incr(by = 1) ⇒ Object
9 10 11 |
# File 'lib/workqueue.rb', line 9 def incr(by=1) mutex.synchronize { @count += by } end |