module Async::Await
Constants
- VERSION
Public Class Methods
included(klass)
click to toggle source
# File lib/async/await.rb, line 28 def self.included(klass) klass.include(Methods) klass.extend(self) end
Public Instance Methods
async(name)
click to toggle source
# File lib/async/await.rb, line 51 def async(name) original_method = instance_method(name) remove_method(name) define_method(name) do |*arguments, &block| Async::Reactor.run do |task| original_method.bind(self).call(*arguments, &block) end end ruby2_keywords(name) end
sync(name)
click to toggle source
# File lib/async/await.rb, line 33 def sync(name) original_method = instance_method(name) remove_method(name) define_method(name) do |*arguments, &block| if task = Task.current? original_method.bind(self).call(*arguments, &block) else Async::Reactor.run do original_method.bind(self).call(*arguments, &block) end.wait end end ruby2_keywords(name) end