Details
-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
Description
The current TimeScheduler2 class has a few deficiencies:
- taskReady() should only set next-execution-time if its argument is less than next-execution-time
- no_tasks: when setting this CAS, the result is only checked in 1 location, but not the other
- Potential loss of task: when calling schedule() on an existing Entry (same execution time), and - before adding the task to Entry - Entry is removed by _run() as it was executed, then the newly added task will never get to run !
- Simplification: instead of headMap(), just use firstEntry(), removeFirstEntry(). See pseudo code below.
As a workaround, timer_type="old" will switch back to the previous default timer. The reason for TimeScheduler3 (versus changing TimeScheduler2) is that we can simply switch to the new impl by setting (a new) timer_type="new2". Should this have a bug, we can simply switch back to "new" or "old" (or "wheel".
Over time, TimeScheduler2 will get removed.
Pseudo code:
- loop while has tasks
- get the first task
- if its time is less than the current time: execute it and remove it
- else block (on the next task or 10s) until an element is added