Skip to content

Commit 90f8287

Browse files
committed
ensure waiting tasks are cancelled on worker unsubscription
1 parent 6efc2cf commit 90f8287

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/java/rx/schedulers/ExecutorScheduler.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,17 @@ public Subscription schedule(Action0 action) {
9696
@Override
9797
public void run() {
9898
do {
99-
if (tasks.isUnsubscribed()) {
100-
queue.clear();
101-
return;
102-
}
103-
10499
ScheduledAction sa = queue.poll();
105100
if (sa == null) {
106101
return;
107102
}
108-
109103
if (!sa.isUnsubscribed()) {
110-
sa.run();
104+
if (!tasks.isUnsubscribed()) {
105+
sa.run();
106+
} else {
107+
queue.clear();
108+
return;
109+
}
111110
}
112111
} while (wip.decrementAndGet() != 0);
113112
}

0 commit comments

Comments
 (0)