28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/web/worker.rb', line 28
def start
return if running?
@worker_thread = Thread.new do
loop do
begin
q = @queue.pop
if canceled?
@queue.clear
@cancel_signal = false
else
@thread_of_block_executing = Thread.new do
q[:block].call
end
@thread_of_block_executing.tap do |th|
th.join
th = nil
end
end
rescue SystemExit
rescue Exception => e
STDOUT.puts $@.shift + ": #{e.message} (#{e.class})"
$@.each do |b|
STDOUT.puts " from #{b}"
end
ensure
if q[:counting]
countdown
notification_queue
end
end
end
end
end
|