You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
When restarting a game it is useful to be able to get rid of any background coroutines while preserving the "main" coroutine. It's important to do this in a way that does not enshrine the "main" coroutine in any way.
One possible approach is to take advantage of the ordered nature of schedules. If coroutine B is farther in the schedule than coroutine A then B guaranteed to have started later than A. If we want to get rid of any coroutines started after a coroutine, we could expose a removeAllAfter(i) method, where i is the offset into the schedule after which to remove coroutines.
SCHED.add(function*(){// "main" coroutineconstdepthAtStart=SCHED.size// or similarwhile(true){// ... coroutine body// when resettingSCHED.removeAllAfter(depthAtStart)}})
removeAllAfter should call return() on the relevant coroutines and allow them to be cleaned up in later ticks.
The text was updated successfully, but these errors were encountered:
When restarting a game it is useful to be able to get rid of any background coroutines while preserving the "main" coroutine. It's important to do this in a way that does not enshrine the "main" coroutine in any way.
One possible approach is to take advantage of the ordered nature of schedules. If coroutine B is farther in the schedule than coroutine A then B guaranteed to have started later than A. If we want to get rid of any coroutines started after a coroutine, we could expose a
removeAllAfter(i)
method, wherei
is the offset into the schedule after which to remove coroutines.removeAllAfter
should callreturn()
on the relevant coroutines and allow them to be cleaned up in latertick
s.The text was updated successfully, but these errors were encountered: