diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_cable/channel/base.rb | 2 | ||||
-rw-r--r-- | lib/action_cable/worker.rb | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index e311cc97e9..af328cf297 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -67,7 +67,7 @@ module ActionCable def start_periodic_timers self.class.periodic_timers.each do |callback, options| @_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do - callback.respond_to?(:call) ? instance_exec(&callback) : send(callback) + Celluloid::Actor[:worker_pool].async.run_periodic_timer(self, callback) end end end diff --git a/lib/action_cable/worker.rb b/lib/action_cable/worker.rb index 46b5f7edc0..1a8bee974b 100644 --- a/lib/action_cable/worker.rb +++ b/lib/action_cable/worker.rb @@ -12,7 +12,15 @@ module ActionCable end def cleanup_subscriptions(connection) - connection.cleanup_subscriptions + run_callbacks :work do + connection.cleanup_subscriptions + end + end + + def run_periodic_timer(channel, callback) + run_callbacks :work do + callback.respond_to?(:call) ? channel.instance_exec(&callback) : channel.send(callback) + end end end |