Method: Thread::Promise#value

Defined in:
lib/thread/promise.rb

#value(timeout = nil) ⇒ Object Also known as: ~

Get the value that’s been delivered, if none has been delivered yet the call will block until one is delivered.

An optional timeout can be passed which will return nil if nothing has been delivered.



49
50
51
52
53
54
55
56
57
# File 'lib/thread/promise.rb', line 49

def value(timeout = nil)
	return @value if delivered?

	@mutex.synchronize {
		cond.wait(@mutex, *timeout)
	}

	return @value if delivered?
end