397769 - TimerScheduler does not relinquish cancelled tasks.

Now the scheduler submits itself as a task that runs every second to purge the task queue.
This commit is contained in:
Simone Bordet 2013-01-24 16:06:20 +01:00
parent 6980a8d9d2
commit 29d2854027

View File

@ -27,7 +27,7 @@ import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
public class TimerScheduler extends AbstractLifeCycle implements Scheduler
public class TimerScheduler extends AbstractLifeCycle implements Scheduler, Runnable
{
private static final Logger LOG = Log.getLogger(TimerScheduler.class);
@ -57,6 +57,7 @@ public class TimerScheduler extends AbstractLifeCycle implements Scheduler
protected void doStart() throws Exception
{
_timer = _name == null ? new Timer() : new Timer(_name, _daemon);
run();
super.doStart();
}
@ -79,6 +80,17 @@ public class TimerScheduler extends AbstractLifeCycle implements Scheduler
return t;
}
@Override
public void run()
{
Timer timer = _timer;
if (timer != null)
{
timer.purge();
schedule(this, 1, TimeUnit.SECONDS);
}
}
private static class SimpleTask extends TimerTask implements Task
{
private final Runnable _task;