class Async::Task

def wait

@returns [Object] The final expression/result of the task's block.
@raises [RuntimeError] If the task's fiber is the current fiber.

Conceptually speaking, waiting on a task should return a result, and if it throws an exception, this is certainly an exceptional case that should represent a failure in your program, not an expected outcome. In other words, you should not design your programs to expect exceptions from `#wait` as a normal flow control, and prefer to catch known exceptions within the task itself and return a result that captures the intention of the failure, e.g. a `TimeoutError` might simply return `nil` or `false` to indicate that the operation did not generate a valid result (as a timeout was an expected outcome of the internal operation in this case).

Retrieve the current result of the task. Will cause the caller to wait until result is available. If the result was an exception, raise that exception.
def wait
	raise "Cannot wait on own fiber!" if Fiber.current.equal?(@fiber)
	
	if running?
		@finished ||= Condition.new
		@finished.wait
	end
	
	if @result.is_a?(Exception)
		raise @result
	else
		return @result
	end
end