function CancelToken.new(R)local k=setmetatable({},CancelToken)assert(type(R)=="\102\117\110\099\116\105\111\110","\066\097\100 \101\120\101\099\117\116\111\114")k.PromiseCancelled=Promise.new()k.Cancelled=Signal.new()k.PromiseCancelled:Then(function()k.Cancelled:Fire()k.Cancelled:Destroy()end)R(function()k:_cancel()end)return k end

function CancelToken.new(executor)
	local self = setmetatable({}, CancelToken)

	assert(type(executor) == "function", "Bad executor")

	self.PromiseCancelled = Promise.new()

	self.Cancelled = Signal.new()

	self.PromiseCancelled:Then(function()
		self.Cancelled:Fire()
		self.Cancelled:Destroy()
	end)

	executor(function()
		self:_cancel()
	end)

	return self
end
