Class: Harness::AsyncQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/harness/async_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAsyncQueue

Returns a new instance of AsyncQueue.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/harness/async_queue.rb', line 7

def initialize
  @queue = Queue.new
  @consumer = Thread.new do
    loop do
      msg = queue.pop

      method_name = msg.first
      args = msg.last

      collector.__send__ method_name, *args
    end
  end
end

Instance Attribute Details

#consumerObject (readonly)

Returns the value of attribute consumer.



5
6
7
# File 'lib/harness/async_queue.rb', line 5

def consumer
  @consumer
end

#queueObject (readonly)

Returns the value of attribute queue.



5
6
7
# File 'lib/harness/async_queue.rb', line 5

def queue
  @queue
end

Instance Method Details

#collectorObject



25
26
27
# File 'lib/harness/async_queue.rb', line 25

def collector
  Harness.collector
end

#push(msg) ⇒ Object



21
22
23
# File 'lib/harness/async_queue.rb', line 21

def push(msg)
  queue.push msg
end