class Async::Promise

def fulfill(&block)

@returns [Object] The result of the block.
@yields {...} The block to call to resolve the promise.
If the promise was already resolved, the block will not be called.
If the block raises an exception, the promise will be rejected.
Resolve the promise with the result of the block.
def fulfill(&block)
	raise "Promise already resolved!" if @resolved
	
	begin
		return self.resolve(yield)
	rescue Cancel => exception
		return self.cancel(exception)
	rescue => error
		return self.reject(error)
	rescue Exception => exception
		self.reject(exception)
		raise
	ensure
		# Handle non-local exits (throw, etc.) that bypass normal flow:
		self.resolve(nil) unless @resolved
	end
end