Permalink
Browse files

Merge pull request #8 from jglick/sleep-info-JENKINS-34281

[JENKINS-34281] Indicate if we are still sleeping after a resume
  • Loading branch information...
jglick committed Jun 9, 2016
2 parents 7360c8d + 3da248c commit f79ae94a60cfcd62d9248e893c4a36573b7d1c61
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/main/java/org/jenkinsci/plugins/workflow/steps/SleepStep.java
@@ -26,6 +26,8 @@
import com.google.inject.Inject;
import hudson.Extension;
import hudson.Util;
import hudson.model.TaskListener;
import hudson.util.ListBoxModel;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -60,6 +62,7 @@ public TimeUnit getUnit() {
private static final long serialVersionUID = 1L;
@Inject(optional=true) private transient SleepStep step;
@StepContextParameter private transient TaskListener listener;
private long end;
private transient volatile ScheduledFuture<?> task;
@@ -72,12 +75,14 @@ public TimeUnit getUnit() {
private void setupTimer(long now) {
if (end > now) {
listener.getLogger().println("Sleeping for " + Util.getTimeSpanString(end - now));
task = Timer.get().schedule(new Runnable() {
@Override public void run() {
getContext().onSuccess(null);
}
}, end - now, TimeUnit.MILLISECONDS);
} else {
listener.getLogger().println("No need to sleep any longer");
getContext().onSuccess(null);
}
}

0 comments on commit f79ae94

Please sign in to comment.