function Maid.GiveTask(o,t)assert(t)local n=#o._tasks+1 o[n]=t return n end function Maid.GivePromise(o,t)if not t:IsPending()then return t end local n=t.resolved(t)local P=o:GiveTask(n)n:Finally(function()o[P]=nil end)return n end
--- Same as indexing, but uses an incremented number as a key.
-- @param task An item to clean
-- @treturn number taskId
function Maid:GiveTask(task)
	assert(task)
	local taskId = #self._tasks + 1
	self[taskId] = task
	return taskId
end

function Maid:GivePromise(promise)
	if not promise:IsPending() then
		return promise
	end

	local newPromise = promise.resolved(promise)
	local id = self:GiveTask(newPromise)

	-- Ensure GC
	newPromise:Finally(function()
		self[id] = nil
	end)

	return newPromise
end
