diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2016-01-27 14:33:15 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2016-01-27 14:33:15 +0100 |
commit | 9ea7aa84d16d99fd32ed1877e3fd6631a41e7042 (patch) | |
tree | ccc4bdf086f9c8d54c40a38213787e212da1af2b /actioncable/lib/action_cable/connection/stream_event_loop.rb | |
parent | 92039d7c7bacfe5747f96047e80f0e8ceb481f62 (diff) | |
download | rails-9ea7aa84d16d99fd32ed1877e3fd6631a41e7042.tar.gz rails-9ea7aa84d16d99fd32ed1877e3fd6631a41e7042.tar.bz2 rails-9ea7aa84d16d99fd32ed1877e3fd6631a41e7042.zip |
Revert "Eliminate the EventMachine dependency"
Diffstat (limited to 'actioncable/lib/action_cable/connection/stream_event_loop.rb')
-rw-r--r-- | actioncable/lib/action_cable/connection/stream_event_loop.rb | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/actioncable/lib/action_cable/connection/stream_event_loop.rb b/actioncable/lib/action_cable/connection/stream_event_loop.rb deleted file mode 100644 index f773814973..0000000000 --- a/actioncable/lib/action_cable/connection/stream_event_loop.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'nio' - -module ActionCable - module Connection - class StreamEventLoop - def initialize - @nio = NIO::Selector.new - @map = {} - @stopping = false - @todo = Queue.new - - Thread.new do - Thread.current.abort_on_exception = true - run - end - end - - def attach(io, stream) - @todo << lambda do - @map[io] = stream - @nio.register(io, :r) - end - @nio.wakeup - end - - def detach(io, stream) - @todo << lambda do - @nio.deregister(io) - @map.delete io - end - @nio.wakeup - end - - def stop - @stopping = true - @nio.wakeup - end - - def run - loop do - if @stopping - @nio.close - break - end - - until @todo.empty? - @todo.pop(true).call - end - - if monitors = @nio.select - monitors.each do |monitor| - io = monitor.io - stream = @map[io] - - begin - stream.receive io.read_nonblock(4096) - rescue IO::WaitReadable - next - rescue EOFError - stream.close - end - end - end - end - end - end - end -end |