Class: Luego::Future
Instance Method Summary collapse
- #await! ⇒ Object
- #delegating? ⇒ Boolean (also: #ready?)
-
#initialize(thread = nil, &block) ⇒ Future
constructor
A new instance of Future.
- #method_missing(*args, &block) ⇒ Object
Methods inherited from Delegate
#delegate!, #send, #undelegate!
Constructor Details
#initialize(thread = nil, &block) ⇒ Future
Returns a new instance of Future.
8 9 10 11 |
# File 'lib/luego/future.rb', line 8 def initialize(thread = nil, &block) @thread = thread || ::Thread.new(&block) @thread.run end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
13 14 15 16 |
# File 'lib/luego/future.rb', line 13 def method_missing(*args, &block) await! super end |
Instance Method Details
#await! ⇒ Object
18 19 20 21 22 |
# File 'lib/luego/future.rb', line 18 def await! return @child unless @child.nil? @child = @thread.value end |
#delegating? ⇒ Boolean Also known as: ready?
24 25 26 |
# File 'lib/luego/future.rb', line 24 def delegating? !@thread.alive? end |