Module: Await

Extended by:
Await
Included in:
Await
Defined in:
lib/await.rb

Defined Under Namespace

Modules: ThreadExtension

Instance Method Summary collapse

Instance Method Details

#await(&block) ⇒ Object

Define a group of operations that need to be completed before execution will continue. The current fiber is suspended until all of the defer operations have completed.



73
74
75
# File 'lib/await.rb', line 73

def await(&block)
  Thread.current.await(&block)
end

#defer(*args, &block) ⇒ Object

Used to define a deferred operation. The return value is a Proc that can be passed through as a callback argument to any method. Once the callback has been executed it is considered complete unless within that callback other defer or await calls are made.



81
82
83
# File 'lib/await.rb', line 81

def defer(*args, &block)
  Thread.current.defer(*args, &block)
end