I'm designing (not writing, yet) a task scheduler system for a complex video game. The rest of the program passes it objects containing a function and some metadata including an estimation of how much time is left before the data is needed (which can change, of course). The scheduler is responsible for prioritizing these tasks and calling the function.
The algorithm I've designed for this problem is pretty simple; it just sorts its list of task objects, pops one off the top, calls it, and repeats. Of course it's actually more complex than that (has to handle situations where things just can't get done on time, telling other parts of the code that their task just got bumped down the list...), but that's the gist of it.
I'd like some advice on the subject of how I'm going to sort that list. This loop will, obviously, be running constantly while the program is running. I'm thinking I'll use a slight modification of a bubble sort algorithm, running one pass on each iteration. The list won't be properly sorted for the first few cycles, but since the list will likely be very small when the program is started I expect it will be able to reliably get things into position as fast as they come in.
Has anyone done this before, and how did it work? Are there better ways I could do this?