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 |
|
} |
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))); |
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), |
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); |
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 |
|
|