1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Run periodic timers via the worker pool

This commit is contained in:
Pratik Naik 2015-02-05 17:02:01 +05:30
parent 7fef6b01a3
commit d9d6ebcac8
2 changed files with 10 additions and 2 deletions

View file

@ -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

View file

@ -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