lib/polyphony/extensions/thread.rb in polyphony-0.44.0 vs lib/polyphony/extensions/thread.rb in polyphony-0.45.0

- old
+ new

@@ -14,25 +14,26 @@ @block = block orig_initialize { execute } end def execute - # agent must be created in the context of the new thread, therefore it + # backend must be created in the context of the new thread, therefore it # cannot be created in Thread#initialize - @agent = Polyphony::Agent.new + @backend = Polyphony::Backend.new setup @ready = true result = @block.(*@args) rescue Polyphony::MoveOn, Polyphony::Terminate => e result = e.value - rescue Exception => result + rescue Exception => e + result = e ensure @ready = true finalize(result) end - attr_accessor :agent + attr_accessor :backend def setup @main_fiber = Fiber.current @main_fiber.setup_main_fiber setup_fiber_scheduling @@ -46,10 +47,10 @@ @finalization_mutex.synchronize do @terminated = true @result = result signal_waiters(result) end - @agent.finalize + @backend.finalize end def signal_waiters(result) @join_wait_queue.each { |w| w.signal(result) } end