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:
But this will leave some suspend coroutines, not sure if these garbage will be collected by collectgarbage("collect")....
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")....