diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-12-06 13:03:30 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-12-06 13:04:53 -0800 |
commit | c4996358a9cd949757f297dfdcc2a71306fc285f (patch) | |
tree | 7c3f30e7689ff0046378f62fad5b74a63a71e645 /lib/rainbows/event_machine.rb | |
parent | 89fa9d73f7976c1e52f53e3e6ccac177cb3251fe (diff) | |
download | rainbows-c4996358a9cd949757f297dfdcc2a71306fc285f.tar.gz |
We'll be adding EventMachine-based concurrency models.
Diffstat (limited to 'lib/rainbows/event_machine.rb')
-rw-r--r-- | lib/rainbows/event_machine.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index 2fa18f1..e81914a 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -173,7 +173,7 @@ module Rainbows return if CUR.size >= MAX io = Rainbows.accept(@io) or return sig = EM.attach_fd(io.fileno, false) - CUR[sig] = Client.new(sig, io) + CUR[sig] = CL.new(sig, io) end end @@ -186,16 +186,18 @@ module Rainbows # enable them both, should be non-fatal if not supported EM.epoll EM.kqueue - logger.info "EventMachine: epoll=#{EM.epoll?} kqueue=#{EM.kqueue?}" + logger.info "#@use: epoll=#{EM.epoll?} kqueue=#{EM.kqueue?}" + client_class = Rainbows.const_get(@use).const_get(:Client) Server.const_set(:MAX, worker_connections + LISTENERS.size) - EvCore.setup(Client) + Server.const_set(:CL, client_class) + EvCore.setup(client_class) EM.run { conns = EM.instance_variable_get(:@conns) or raise RuntimeError, "EM @conns instance variable not accessible!" Server.const_set(:CUR, conns) EM.add_periodic_timer(1) do unless G.tick - conns.each_value { |client| Client === client and client.quit } + conns.each_value { |c| client_class === c and c.quit } EM.stop if conns.empty? && EM.reactor_running? end end |