Module: Is::Async

Overview

public

Makes Ruby objects async-aware.

Instance Method Summary collapse

Instance Method Details

#asyncObject

public

Call behavior asychronously, returning a future.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/is/async.rb', line 14

def async
  if block_given?
    task = ::Async::Reactor.run { |current|
      begin
        yield
      ensure
        current.yield
      end
    }

    Core::Async::Future.new(task)
  else
    Core::Async::Wrapper.new(self)
  end
end