Skip to content

Commit

Permalink
ensure waiting tasks are cancelled on worker unsubscription
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmoten committed Apr 19, 2016
1 parent 6efc2cf commit 90f8287
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/rx/schedulers/ExecutorScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ public Subscription schedule(Action0 action) {
@Override
public void run() {
do {
if (tasks.isUnsubscribed()) {
queue.clear();
return;
}

ScheduledAction sa = queue.poll();
if (sa == null) {
return;
}

if (!sa.isUnsubscribed()) {
sa.run();
if (!tasks.isUnsubscribed()) {
sa.run();
} else {
queue.clear();
return;
}
}
} while (wip.decrementAndGet() != 0);
}
Expand Down

0 comments on commit 90f8287

Please sign in to comment.