Sorry for the stupid name: I could not think of anything better. I need to develop a program that will simulate a certain time line (not coinciding with the real, of course), for example, using the main loop, where each iteration will be the second of this imitation time line (as a "tick" in game engines); there will also be events at different moments of simulation time, there will be a lot of events, new programs may appear during program execution, and they should be processed in parallel. Let's say there is a queue where elements can be written to, and a handler where they are processed (unexpectedly). If the queue is full, then the element will return false , otherwise it will fall into the queue and will wait for the processing of all those ahead. The bottom line is that all this should happen in parallel, but I can not imagine a normal implementation. Now thoughts are only about a monstrous array, where events and timecode will be recorded, and in the main loop there will be a check, like this (pseudocode):
for (int i = 1; i < renderTime; i++) { switch (eventLine[i]) { case "addItem": foo(); case "finalizeItem": bar(); } }
действие => таймкодand follow it? - Urffly