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

	@param executor (cancel: () -> ()) -> ()
	@return CancelToken
]=]
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
