lib/async/container/threaded.rb in async-container-0.7.0 vs lib/async/container/threaded.rb in async-container-0.8.0
- old
+ new
@@ -25,10 +25,20 @@
module Async
module Container
# Manages a reactor within one or more threads.
class Threaded
+ class Instance
+ def initialize(thread)
+ @thread = thread
+ end
+
+ def name= value
+ @thread.name = value
+ end
+ end
+
def initialize(concurrency: 1, name: nil, &block)
@reactors = concurrency.times.collect do
Async::Reactor.new
end
@@ -38,10 +48,10 @@
thread.abort_on_exception = true
thread.name = name if name
begin
- reactor.run(&block)
+ reactor.run(Instance.new(thread), &block)
rescue Interrupt
# Exit cleanly.
end
end
end