Class: IFuture
- Inherits:
-
Object
- Object
- IFuture
- Defined in:
- lib/ifuture.rb,
lib/ifuture/version.rb
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Method Summary collapse
-
#initialize(&block) ⇒ IFuture
constructor
A new instance of IFuture.
- #ready? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(&block) ⇒ IFuture
Returns a new instance of IFuture.
5 6 7 8 9 10 11 |
# File 'lib/ifuture.rb', line 5 def initialize &block @channel = IChannel.new Marshal @pid = fork do @channel.put block.call end end |
Instance Method Details
#ready? ⇒ Boolean
13 14 15 16 17 18 19 |
# File 'lib/ifuture.rb', line 13 def ready? begin !Process.getpgid(@pid) rescue Errno::ESRCH true end end |
#value ⇒ Object
21 22 23 24 |
# File 'lib/ifuture.rb', line 21 def value Process.wait @pid @channel.get end |