class Async::Promise

def wait(...)

@raises [Async::TimeoutError] If timeout expires before the promise is resolved.
@raises [Exception] The rejected or cancelled exception.
@returns [Object] The resolved value.

If already resolved, returns immediately. If rejected, raises the stored exception.

Wait for the promise to be resolved and return the value.
def wait(...)
	resolved = wait?(...)
	
	if resolved.nil?
		raise TimeoutError, "Timeout while waiting for promise!"
	elsif resolved == :completed
		return @value
	elsif @value
		# If we aren't completed, we should have an exception or cancel reason stored:
		raise @value
	end
end