Class: RbEAI::Control
- Inherits:
-
Object
- Object
- RbEAI::Control
- Defined in:
- lib/rbeai/PipeTask.rb
Instance Attribute Summary collapse
-
#control ⇒ Object
Returns the value of attribute control.
-
#controlQueue ⇒ Object
Returns the value of attribute controlQueue.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(controlQueue, dataQueue) ⇒ Control
constructor
A new instance of Control.
- #start(threadPool) ⇒ Object
- #waitJoin ⇒ Object
Constructor Details
#initialize(controlQueue, dataQueue) ⇒ Control
Returns a new instance of Control.
10 11 12 13 |
# File 'lib/rbeai/PipeTask.rb', line 10 def initialize(controlQueue, dataQueue) @controlQueue = controlQueue @dataQueue = dataQueue end |
Instance Attribute Details
#control ⇒ Object
Returns the value of attribute control.
8 9 10 |
# File 'lib/rbeai/PipeTask.rb', line 8 def control @control end |
#controlQueue ⇒ Object
Returns the value of attribute controlQueue.
8 9 10 |
# File 'lib/rbeai/PipeTask.rb', line 8 def controlQueue @controlQueue end |
Instance Method Details
#finish ⇒ Object
31 32 33 |
# File 'lib/rbeai/PipeTask.rb', line 31 def finish() @controlQueue.enq(:FINISH_THREADS) end |
#start(threadPool) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rbeai/PipeTask.rb', line 15 def start(threadPool) @control = Thread.new() do #print "Running control thread \n" begin obj = @controlQueue.deq end until obj == :FINISH_THREADS threadPool.size.times { @dataQueue.enq(:FINISH_WORK) } threadPool.waitJoinAll() #print "Finished control thread \n" end end |
#waitJoin ⇒ Object
27 28 29 |
# File 'lib/rbeai/PipeTask.rb', line 27 def waitJoin() @control.join() end |