Skip to content

Commit

Permalink
Make sure cancelled scheduled tasks will not run again if cancelled b…
Browse files Browse the repository at this point in the history
…efore
  • Loading branch information
Norman Maurer committed Mar 22, 2013
1 parent 28576aa commit 624bda4
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -800,16 +800,19 @@ public void run() {
setSuccessInternal(result);
}
} else {
task.call();
if (!executor().isShutdown()) {
long p = periodNanos;
if (p > 0) {
deadlineNanos += p;
} else {
deadlineNanos = nanoTime() - p;
}
if (!isDone()) {
executor().delayedTaskQueue.add(this);
// check if is done as it may was cancelled
if (!isDone()) {
task.call();
if (!executor().isShutdown()) {
long p = periodNanos;
if (p > 0) {
deadlineNanos += p;
} else {
deadlineNanos = nanoTime() - p;
}
if (!isDone()) {
executor().delayedTaskQueue.add(this);
}
}
}
}
Expand Down

0 comments on commit 624bda4

Please sign in to comment.