File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 20
20
import rx .functions .Action0 ;
21
21
import rx .schedulers .Schedulers ;
22
22
import rx .subscriptions .MultipleAssignmentSubscription ;
23
+ import rx .subscriptions .SerialSubscription ;
23
24
24
25
/**
25
26
* A {@code Scheduler} is an object that schedules units of work. You can find common implementations of this
@@ -119,11 +120,17 @@ public void call() {
119
120
if (!mas .isUnsubscribed ()) {
120
121
action .call ();
121
122
long nextTick = startInNanos + (++count * periodInNanos );
122
- mas .set (schedule (this , nextTick - TimeUnit .MILLISECONDS .toNanos (now ()), TimeUnit .NANOSECONDS ));
123
+ SerialSubscription s = new SerialSubscription ();
124
+ // Should call `mas.set` before `schedule`, or the new Subscription may replace the old one.
125
+ mas .set (s );
126
+ s .set (schedule (this , nextTick - TimeUnit .MILLISECONDS .toNanos (now ()), TimeUnit .NANOSECONDS ));
123
127
}
124
128
}
125
129
};
126
- mas .set (schedule (recursiveAction , initialDelay , unit ));
130
+ SerialSubscription s = new SerialSubscription ();
131
+ // Should call `mas.set` before `schedule`, or the new Subscription may replace the old one.
132
+ mas .set (s );
133
+ s .set (schedule (recursiveAction , initialDelay , unit ));
127
134
return mas ;
128
135
}
129
136
You can’t perform that action at this time.
0 commit comments