aboutsummaryrefslogblamecommitdiffstats
path: root/actioncable/lib/action_cable/subscription_adapter/async.rb
blob: 9169734471ddd1fea3253f2cf98495e0ad5879b5 (plain) (tree)
1
2
3
4
5
6
7
8
                         




                                  
                              
                                                   


                                                




                                    
                               
                                      


                                
                                      




             
require_relative "inline"

module ActionCable
  module SubscriptionAdapter
    class Async < Inline # :nodoc:
      private
        def new_subscriber_map
          AsyncSubscriberMap.new(server.event_loop)
        end

        class AsyncSubscriberMap < SubscriberMap
          def initialize(event_loop)
            @event_loop = event_loop
            super()
          end

          def add_subscriber(*)
            @event_loop.post { super }
          end

          def invoke_callback(*)
            @event_loop.post { super }
          end
        end
    end
  end
end