Class: Fibril::Future
- Inherits:
-
Object
- Object
- Fibril::Future
- Defined in:
- lib/fibril/future.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#future_thread ⇒ Object
Returns the value of attribute future_thread.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #await ⇒ Object
- #close ⇒ Object
-
#initialize(&blk) ⇒ Future
constructor
A future.
Constructor Details
#initialize(&blk) ⇒ Future
A future. A very thin wrapper around a thread. Can be used within ‘await` and `await_all` within a fibril
9 10 11 |
# File 'lib/fibril/future.rb', line 9 def initialize(&blk) self.future_thread = Thread.new(&blk) end |
Instance Attribute Details
#future_thread ⇒ Object
Returns the value of attribute future_thread.
2 3 4 |
# File 'lib/fibril/future.rb', line 2 def future_thread @future_thread end |
Instance Method Details
#alive? ⇒ Boolean
17 18 19 |
# File 'lib/fibril/future.rb', line 17 def alive? self.future_thread.alive? end |
#await ⇒ Object
13 14 15 |
# File 'lib/fibril/future.rb', line 13 def await self.future_thread.join.value end |
#close ⇒ Object
21 22 23 |
# File 'lib/fibril/future.rb', line 21 def close self.future_thread.kill end |