Class: RbEAI::Control

Inherits:
Object
  • Object
show all
Defined in:
lib/rbeai/PipeTask.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#controlObject

Returns the value of attribute control.



8
9
10
# File 'lib/rbeai/PipeTask.rb', line 8

def control
  @control
end

#controlQueueObject

Returns the value of attribute controlQueue.



8
9
10
# File 'lib/rbeai/PipeTask.rb', line 8

def controlQueue
  @controlQueue
end

Instance Method Details

#finishObject



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

#waitJoinObject



27
28
29
# File 'lib/rbeai/PipeTask.rb', line 27

def waitJoin()
  @control.join()
end