function Promise.prototype.cancel(s)if s._status~=Promise.Status.Started then return end s._status=Promise.Status.Cancelled if s._cancellationHook then s._cancellationHook()end if s._parent then s._parent:_consumerCancelled(s)end for s in pairs(s._consumers)do s:cancel()end s:_finalize()end

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
