function Promise.prototype.cancel(w)if w._status~=Promise.Status.Started then return end w._status=Promise.Status.Cancelled if w._cancellationHook then w._cancellationHook()end if w._parent then w._parent:_consumerCancelled(w)end for w in pairs(w._consumers)do w:cancel()end w:_finalize()end function Promise.prototype.Destroy(w)w:cancel()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


function Promise.prototype:Destroy()
	self:cancel()
end
