ActionCable::Connection::StreamEventLoop Ruby on Rails 5.1.2 Class ActionCable::Connection::StreamEventLoop < Object actioncable/lib/action_cable/connection/stream_event_loop.rb Methods A attach D detach N new P post S stop T timer W writes_pending Class Public methods new() Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 7 def initialize @nio = @executor = @thread = nil @map = {} @stopping = false @todo = Queue.new @spawn_mutex = Mutex.new end Instance Public methods attach(io, stream) Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 27 def attach(io, stream) @todo << lambda do @map[io] = @nio.register(io, :r) @map[io].value = stream end wakeup end detach(io, stream) Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 35 def detach(io, stream) @todo << lambda do @nio.deregister io @map.delete io io.close end wakeup end post(task = nil, &block) Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 20 def post(task = nil, &block) task ||= block spawn @executor << task end stop() Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 53 def stop @stopping = true wakeup if @nio end timer(interval, &block) Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 16 def timer(interval, &block) Concurrent::TimerTask.new(execution_interval: interval, &block).tap(&:execute) end writes_pending(io) Link Source: show | on GitHub # File actioncable/lib/action_cable/connection/stream_event_loop.rb, line 44 def writes_pending(io) @todo << lambda do if monitor = @map[io] monitor.interests = :rw end end wakeup end