diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2016-06-29 23:15:16 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-06-29 23:37:07 -0700 |
commit | ba9571e1ace2e9a41c3460f7d5eaef17178d637d (patch) | |
tree | a1767104e22002b8fea6c7c8bb0779fa84f4e5a7 /actioncable/lib/action_cable/server | |
parent | fe054e02b29340c6d9265f9b4ea2ea7d9a872156 (diff) | |
download | rails-ba9571e1ace2e9a41c3460f7d5eaef17178d637d.tar.gz rails-ba9571e1ace2e9a41c3460f7d5eaef17178d637d.tar.bz2 rails-ba9571e1ace2e9a41c3460f7d5eaef17178d637d.zip |
Periodic timers: delegate async instance_exec to the worker pool
Diffstat (limited to 'actioncable/lib/action_cable/server')
-rw-r--r-- | actioncable/lib/action_cable/server/worker.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/actioncable/lib/action_cable/server/worker.rb b/actioncable/lib/action_cable/server/worker.rb index a638ff72e7..f3a4fc5a5b 100644 --- a/actioncable/lib/action_cable/server/worker.rb +++ b/actioncable/lib/action_cable/server/worker.rb @@ -42,16 +42,20 @@ module ActionCable self.connection = nil end - def async_invoke(receiver, method, *args, connection: receiver) + def async_exec(receiver, *args, connection:, &block) + async_invoke receiver, :instance_exec, *args, connection: connection, &block + end + + def async_invoke(receiver, method, *args, connection: receiver, &block) @executor.post do - invoke(receiver, method, *args, connection: connection) + invoke(receiver, method, *args, connection: connection, &block) end end - def invoke(receiver, method, *args, connection:) + def invoke(receiver, method, *args, connection:, &block) work(connection) do begin - receiver.send method, *args + receiver.send method, *args, &block rescue Exception => e logger.error "There was an exception - #{e.class}(#{e.message})" logger.error e.backtrace.join("\n") |