function Promise.prototype.cancel(H)if H._status~=Promise.Status.Started then return end H._status=Promise.Status.Cancelled if H._cancellationHook then H._cancellationHook()end if H._parent then H._parent:_consumerCancelled(H)end for H in pairs(H._consumers)do H:cancel()end H:_finalize()end
--[[
	Cancels the promise, disallowing it from rejecting or resolving, and calls
	the cancellation hook if provided.
]]
function Promise.prototype:cancel()
	if self._status ~= Promise.Status.Started then
		return
	end

	self._status = Promise.Status.Cancelled

	if self._cancellationHook then
		self._cancellationHook()
	end

	if self._parent then
		self._parent:_consumerCancelled(self)
	end

	for child in pairs(self._consumers) do
		child:cancel()
	end

	self:_finalize()
end
