function Maid.GiveTask(O,b)assert(b)local I=#O._tasks+1 O[I]=b return I end function Maid.GivePromise(O,b)if not b:IsPending()then return b end local I=b.resolved(b)local T=O:GiveTask(I)I:Finally(function()O[T]=nil end)return I end

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
