ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CompletableFuture.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CompletableFuture.java (file contents):
Revision 1.157 by jsr166, Thu Jan 15 18:34:18 2015 UTC vs.
Revision 1.158 by dl, Sat Jan 17 20:05:02 2015 UTC

# Line 433 | Line 433 | public class CompletableFuture<T> implem
433          abstract boolean isLive();
434  
435          public final void run()                { tryFire(ASYNC); }
436 <        public final boolean exec()            { tryFire(ASYNC); return true; }
436 >        public final boolean exec()            { tryFire(ASYNC); return false; }
437          public final Void getRawResult()       { return null; }
438          public final void setRawResult(Void v) {}
439      }
# Line 2496 | Line 2496 | public class CompletableFuture<T> implem
2496       * @since 1.9
2497       */
2498      public CompletableFuture<T> orTimeout(long timeout, TimeUnit unit) {
2499 +        if (unit == null)
2500 +            throw new NullPointerException();
2501          if (result == null)
2502              whenComplete(new Canceller(Delayer.delay(new Timeout(this),
2503                                                       timeout, unit)));
# Line 2516 | Line 2518 | public class CompletableFuture<T> implem
2518       */
2519      public CompletableFuture<T> completeOnTimeout(T value, long timeout,
2520                                                    TimeUnit unit) {
2521 +        if (unit == null)
2522 +            throw new NullPointerException();
2523          if (result == null)
2524              whenComplete(new Canceller(Delayer.delay(
2525                                             new DelayedCompleter<T>(this, value),
# Line 2602 | Line 2606 | public class CompletableFuture<T> implem
2606       * Singleton delay scheduler, used only for starting and
2607       * cancelling tasks.
2608       */
2609 <    static final class Delayer extends ScheduledThreadPoolExecutor {
2609 >    static final class Delayer {
2610 >        static ScheduledFuture<?> delay(Runnable command, long delay,
2611 >                                        TimeUnit unit) {
2612 >            return delayer.schedule(command, delay, unit);
2613 >        }
2614 >
2615          static final class DaemonThreadFactory implements ThreadFactory {
2616              public Thread newThread(Runnable r) {
2617                  Thread t = new Thread(r);
# Line 2611 | Line 2620 | public class CompletableFuture<T> implem
2620                  return t;
2621              }
2622          }
2623 <        Delayer() {
2624 <            super(1, new DaemonThreadFactory());
2625 <            setRemoveOnCancelPolicy(true);
2626 <        }
2627 <        static final Delayer instance = new Delayer();
2628 <
2620 <        public static ScheduledFuture<?> delay(Runnable command,
2621 <                                               long delay,
2622 <                                               TimeUnit unit) {
2623 <            return instance.schedule(command, delay, unit);
2623 >
2624 >        static final ScheduledThreadPoolExecutor delayer;
2625 >        static {
2626 >            (delayer = new ScheduledThreadPoolExecutor(
2627 >                1, new DaemonThreadFactory())).
2628 >                setRemoveOnCancelPolicy(true);
2629          }
2630      }
2631  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines