Skip to content

Commit

Permalink
Merge pull request #236 from mairbek/sleepingfix
Browse files Browse the repository at this point in the history
Fixed Sleeping Action
  • Loading branch information
benjchristensen committed Apr 18, 2013
2 parents b66557c + 00a362e commit 34e097b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rxjava-core/src/main/java/rx/concurrency/SleepingAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ public SleepingAction(Func2<Scheduler, T, Subscription> underlying, Scheduler sc

@Override
public Subscription call(Scheduler s, T state) {
if (execTime < scheduler.now()) {
if (execTime > scheduler.now()) {
long delay = execTime - scheduler.now();
if (delay> 0) {
try {
Thread.sleep(scheduler.now() - execTime);
} catch (InterruptedException e) {
Thread.sleep(delay);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
}

return underlying.call(s, state);
Expand Down

0 comments on commit 34e097b

Please sign in to comment.