mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-03 12:29:31 +00:00
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:
parent
6980a8d9d2
commit
29d2854027
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user