|
20 | 20 | import static com.google.common.util.concurrent.Internal.toNanosSaturated;
|
21 | 21 | import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
|
22 | 22 | import static java.util.Objects.requireNonNull;
|
| 23 | +import static java.util.concurrent.TimeUnit.NANOSECONDS; |
23 | 24 |
|
24 | 25 | import com.google.common.annotations.GwtIncompatible;
|
25 | 26 | import com.google.common.base.Supplier;
|
@@ -128,7 +129,7 @@ public abstract static class Scheduler {
|
128 | 129 | */
|
129 | 130 | public static Scheduler newFixedDelaySchedule(Duration initialDelay, Duration delay) {
|
130 | 131 | return newFixedDelaySchedule(
|
131 |
| - toNanosSaturated(initialDelay), toNanosSaturated(delay), TimeUnit.NANOSECONDS); |
| 132 | + toNanosSaturated(initialDelay), toNanosSaturated(delay), NANOSECONDS); |
132 | 133 | }
|
133 | 134 |
|
134 | 135 | /**
|
@@ -165,7 +166,7 @@ public Cancellable schedule(
|
165 | 166 | */
|
166 | 167 | public static Scheduler newFixedRateSchedule(Duration initialDelay, Duration period) {
|
167 | 168 | return newFixedRateSchedule(
|
168 |
| - toNanosSaturated(initialDelay), toNanosSaturated(period), TimeUnit.NANOSECONDS); |
| 169 | + toNanosSaturated(initialDelay), toNanosSaturated(period), NANOSECONDS); |
169 | 170 | }
|
170 | 171 |
|
171 | 172 | /**
|
@@ -722,6 +723,14 @@ public Schedule(long delay, TimeUnit unit) {
|
722 | 723 | this.delay = delay;
|
723 | 724 | this.unit = checkNotNull(unit);
|
724 | 725 | }
|
| 726 | + |
| 727 | + /** |
| 728 | + * @param delay the time from now to delay execution |
| 729 | + * @since NEXT |
| 730 | + */ |
| 731 | + public Schedule(Duration delay) { |
| 732 | + this(toNanosSaturated(delay), NANOSECONDS); |
| 733 | + } |
725 | 734 | }
|
726 | 735 |
|
727 | 736 | /**
|
|
0 commit comments