clear un-fired resume timers and triggers

Posted by Unia_nt on Tue 29 Dec 2015 01:46 PM — 1 posts, 7,839 views.

#0
in some scenario where need a trigger to break the coroutine loop, say search in a maze, find something will stop the search, when this trigger fired, we may need clear all pending triggers and timers created by wait module. So I add below function to do this:


function wait.clearall()
    if not next(threads) then
        return
    end
	for k, _ in pairs(threads) do
		DeleteTimer(k)
		DeleteTrigger(k)
	end
	threads={}
    --print("debug:some coroutine entries have been deleted.")
end


But this will leave some suspend coroutines, not sure if these garbage will be collected by collectgarbage("collect")....