Skip to content

Commit 34e097b

Browse files
Merge pull request #236 from mairbek/sleepingfix
Fixed Sleeping Action
2 parents b66557c + 00a362e commit 34e097b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rxjava-core/src/main/java/rx/concurrency/SleepingAction.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ public SleepingAction(Func2<Scheduler, T, Subscription> underlying, Scheduler sc
3434

3535
@Override
3636
public Subscription call(Scheduler s, T state) {
37-
if (execTime < scheduler.now()) {
37+
if (execTime > scheduler.now()) {
38+
long delay = execTime - scheduler.now();
39+
if (delay> 0) {
3840
try {
39-
Thread.sleep(scheduler.now() - execTime);
40-
} catch (InterruptedException e) {
41+
Thread.sleep(delay);
42+
}
43+
catch (InterruptedException e) {
4144
Thread.currentThread().interrupt();
4245
throw new RuntimeException(e);
4346
}
47+
}
4448
}
4549

4650
return underlying.call(s, state);

0 commit comments

Comments
 (0)