aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/subscription_adapter/async.rb
blob: 96c18c4a2fdb6b4c53a4a46d3b43ece561472de2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

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