Class: RbbtThreadQueue::RbbtThreadQueueWorker
- Inherits:
-
Thread
- Object
- Thread
- RbbtThreadQueue::RbbtThreadQueueWorker
- Defined in:
- lib/rbbt/util/concurrency/threads.rb
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(queue, mutex = nil, &block) ⇒ RbbtThreadQueueWorker
constructor
A new instance of RbbtThreadQueueWorker.
Constructor Details
#initialize(queue, mutex = nil, &block) ⇒ RbbtThreadQueueWorker
Returns a new instance of RbbtThreadQueueWorker.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rbbt/util/concurrency/threads.rb', line 5 def initialize(queue, mutex = nil, &block) if mutex.nil? super(Thread.current) do |parent| begin loop do p = queue.pop block.call *p end rescue Exception raise $! end end else super(Thread.current) do |parent| begin loop do p = queue.pop p = Array === p ? p << mutex : [p,mutex] block.call *p end rescue Exception raise $! end end end end |
Instance Method Details
#clean ⇒ Object
32 33 34 |
# File 'lib/rbbt/util/concurrency/threads.rb', line 32 def clean raise Aborted if alive? end |