default <R> Task<R> apply(final String desc, final PromisePropagator<T, R> propagator) { return FusionTask.create(desc, this, propagator); }
/** * Creates a new task that will be resolved with given value when it is * executed. Note that this task is not initially completed. * * @param <T> type of the value * @param desc a description of the value, it will show up in a trace * @param value a value the task will be resolved with * @return new task that will be resolved with given value when it is * executed */ public static <T> Task<T> value(final String desc, final T value) { return FusionTask.create(desc, (src, dst) -> { dst.done(value); } ); }
/** * Creates a new task that will be fail with given exception when it is * executed. Note that this task is not initially completed. * * @param <T> type parameter of the returned task * @param desc a description of the failure, it will show up in a trace * @param failure a failure the task will fail with * @return new task that will fail with given failure when it is * executed */ public static <T> Task<T> failure(final String desc, final Throwable failure) { ArgumentUtil.requireNotNull(failure, "failure"); return FusionTask.create(desc, (src, dst) -> { dst.fail(failure); } ); }
return FusionTask.create(name, (src, dst) -> { try { dst.done(callable.call());
default <R> Task<R> apply(final String desc, final PromisePropagator<T, R> propagator) { return FusionTask.create(desc, this, propagator); }
/** * Creates a new task that will be resolved with given value when it is * executed. Note that this task is not initially completed. * * @param <T> type of the value * @param desc a description of the value, it will show up in a trace * @param value a value the task will be resolved with * @return new task that will be resolved with given value when it is * executed */ public static <T> Task<T> value(final String desc, final T value) { return FusionTask.create(desc, (src, dst) -> { dst.done(value); } ); }
/** * Creates a new task that will be fail with given exception when it is * executed. Note that this task is not initially completed. * * @param <T> type parameter of the returned task * @param desc a description of the failure, it will show up in a trace * @param failure a failure the task will fail with * @return new task that will fail with given failure when it is * executed */ public static <T> Task<T> failure(final String desc, final Throwable failure) { ArgumentUtil.requireNotNull(failure, "failure"); return FusionTask.create(desc, (src, dst) -> { dst.fail(failure); } ); }
return FusionTask.create(name, (src, dst) -> { try { dst.done(callable.call());