3
4
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
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/irrc/runner.rb', line 3
def run(threads)
done = []
loop do
if last_thread_of?(threads) && @queue.empty?
terminate
logger.debug "Queue #{threads - 1} guard objects"
(threads - 1).times { @queue.push nil }
return done
end
query = @queue.pop
if query.nil?
terminate
return done
end
connect unless established?
begin
logger.info "Processing #{query.object}"
query = process(query)
query.success
logger.debug "Queue new #{query.children.size} queries"
query.children.each {|q| @queue << q }
rescue
logger.error "#{$!.message} when processing #{query.object} for #{query.root.object}"
query.fail
end
done << query if query.root?
end
end
|