module Kernel
Public Instance Methods
future(timeout:nil, &block)
click to toggle source
Creates a new future.
@example Evaluate an operation in another thread
x = future { 3 + 3 }
@yield []
A block to be optimistically evaluated in another thread.
@yieldreturn [Object]
The return value of the block will be the evaluated value of the future.
@return [Future]
# File lib/promising.rb, line 32 def future(timeout:nil, &block) ::Promising::Future.new(timeout:timeout, &block) end
promise(timeout:nil,&block)
click to toggle source
Creates a new promise.
@example Lazily evaluate an arithmetic operation
x = promise { 3 + 3 }
@yield []
A block to be lazily evaluated.
@yieldreturn [Object]
The return value of the block will be the lazily evaluated value of the promise.
@return [Promise]
# File lib/promising.rb, line 17 def promise(timeout:nil,&block) ::Promising::Promise.new(timeout:timeout,&block) end