[PATCH] event_machine: join reactor_thread if it is already running rather than falling through worker_loop

Mark J. Titorenko mark.titorenko at alces-software.com
Fri Jan 11 11:57:12 UTC 2013


Prior to the application of this patch, if an EventMachine reactor_thread has already been started elsewhere before the worker_loop is entered, the worker_loop exits as a second call to EM.run does not block the current thread.

This patch causes the worker_loop thread to join the reactor_thread if it is running.

Cheers,

Mark.

---
 lib/rainbows/event_machine.rb |    1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index 3ecdb4f..b143b39 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -99,6 +99,7 @@ module Rainbows::EventMachine
         end
       end
     }
+    EM.reactor_thread.join if EM.reactor_running?
   end
 end
 # :enddoc:
-- 
1.7.9.6 (Apple Git-31.1)



More information about the rainbows-talk mailing list