module BubbleWrap::Reactor::Future

Public Instance Methods

future(arg, cb=nil, eb=nil, &blk) click to toggle source

A future is a sugaring of a typical deferrable usage.

# File motion/reactor/future.rb, line 6
def future arg, cb=nil, eb=nil, &blk
  arg = arg.call if arg.respond_to?(:call)

  if arg.respond_to?(:set_deferred_status)
    if cb || eb
      arg.callback(&cb) if cb
      arg.errback(&eb) if eb
    else
      arg.callback(&blk) if blk
    end
  end

  arg
end