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
63
|
# File 'lib/web/web_worker.rb', line 36
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.join
@thread_of_block_executing = nil
end
rescue SystemExit
rescue Exception => e
output_error($stdout, e)
ensure
if q && q[:counting]
countdown
end
end
end
end
end
|