[jboss-jira] [JBoss JIRA] (JGRP-1553) TimeScheduler3
Bela Ban (JIRA)
jira-events at lists.jboss.org
Wed Dec 19 06:57:08 EST 2012
[ https://issues.jboss.org/browse/JGRP-1553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12742394#comment-12742394 ]
Bela Ban commented on JGRP-1553:
--------------------------------
I actually ended up implementing TimeScheduler3. It uses a DelayQueue with tasks sorted according to execution time. TimeScheduler is much smaller (300 LOC) than TimeScheduler2 (650 LOC), much more elegant (no awkward referencing of runnables and wrapping done anymore) and much simpler.
I also added more tests to TimeSchedulerTest and TimeScheduler3 passes all.
I changed the default to use the new class (timer_type=new3 in TP).
> TimeScheduler3
> --------------
>
> Key: JGRP-1553
> URL: https://issues.jboss.org/browse/JGRP-1553
> Project: JGroups
> Issue Type: Enhancement
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 3.3
>
>
> 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
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list