Quote:
Originally Posted by lectricpharaoh
This won't work. This brings you full-circle to your original problem.
Picture this. You add an event that should fire after 10 seconds. You then add an event that should fire after 5 seconds, so it goes to the front of the queue. When it fires, you see the event that has a 10-second delay, and set the timer accordingly. The problem, however, is that 5 seconds have elapsed, so when the 10-second delay expires, it will have been 15 seconds.
|
Quote:
|
Originally Posted by kruptof
En-queue items as normal (using the delay time not the due time), set the timer interval to the one add the head of the queue, when that item is de-queue subtract that items time from the one at the head of the queue, if it's 0 de-queue
|
Items in the queue: 5(item1) 10(item2)
5 seconds pass:
dequeue item1, now subtract 5(item1's time) from the item at the head of the queue(item2), not zero so set the interval to 5. Now put all items that were dequeued back into the queue (with their original times).
Items in the queue: 5 (item2), 5 item(1)
5 seconds pass: (in total 10 seconds have passed)
Dequeue item2(because it's at the head of the queue), now subtract 5(item2's time) from the item at the head of the queue(item1), 5-5 = 0, now also dequeue item1.Now put all items that were dequeued back into the queue.(with their original times).
items in the queue5(item1) 10 (item2)
..and so on