Coroutines with time scheduling

Thanks. Not exactly what I’m after. The purpose of the code is to run cooperative multi-agent simulation, and therefore I don’t want delay() to respect real-time clocks, but simply use it to order cooperation. That means that if I do waitUntil(1week), I don’t want the program to wait for a week, but rather switch to the co-routine which had a “waitUntil()” waking up the earliest. It is almost like I would write my own scheduler, sorting the coroutines by the order of their waitUnti().

I re-read the explanation of suspendCoroutine() and I see how it can play a role, by only resuming if the “engine clock” time is already equal or greater than the waitUntil parameter. I’d see a “low priority co-routine” - whatever that might be - just incrementing the engine clock one by one. Instead I think that I’d need to tap into the scheduling logic to decide myself what should be the next suspended function to “wake-up”, after making sure I advanced the engine clock to the earliest parameter of the waitUntil…

Where is the implementation of “such scheduler” currently ?

Thanks