public final class AsyncCompute extends Object
asyncSupply
,
and asyncRun
methods.Modifier and Type | Method and Description |
---|---|
static CompletableFuture<?> |
asyncRun(Executor executor,
long timeout,
TimeUnit unit,
Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
This method will create a
CompletableFuture and will run the given runAsync procedure
asynchronously, by calling it on the given executor , passing the created future to it. |
static CompletableFuture<?> |
asyncRun(Executor executor,
Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
This method will create a
CompletableFuture and will run the given runAsync procedure
asynchronously, by calling it on the given executor , passing the created future to it. |
static CompletableFuture<?> |
asyncRun(Executor executor,
ScheduledExecutorService scheduler,
long timeout,
TimeUnit unit,
Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
This method will create a
CompletableFuture and will run the given runAsync procedure
asynchronously, by calling it on the given executor , passing the created future to it. |
static CompletableFuture<?> |
asyncRun(long timeout,
TimeUnit unit,
Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
Calls
asyncRun(Executor,long,TimeUnit,(CompletableFuture<?>)=>void) with
the common ForkJoinPool as the executor. |
static CompletableFuture<?> |
asyncRun(Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
Calls
asyncRun(Executor,(CompletableFuture<?>)=>void) with
the common ForkJoinPool as the executor. |
static <R> CompletableFuture<R> |
asyncSupply(Executor executor,
Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
This method will call the given
runAsync function using the provided executor . |
static <R> CompletableFuture<R> |
asyncSupply(Executor executor,
long timeout,
TimeUnit unit,
Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
This method will call the given
runAsync function using the given executor . |
static <R> CompletableFuture<R> |
asyncSupply(Executor executor,
ScheduledExecutorService scheduler,
long timeout,
TimeUnit unit,
Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
This method will call the given
runAsync function using the given executor . |
static <R> CompletableFuture<R> |
asyncSupply(Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
This method will call the given
runAsync function using the common ForkJoinPool passing
in a new CompletableFuture which is also being returned from this method. |
static <R> CompletableFuture<R> |
asyncSupply(long timeout,
TimeUnit unit,
Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
This method will call the given
runAsync function using the common ForkJoinPool with the CompletableFuture
being returned. |
static <R> CompletableFuture<R> |
asyncSupply(ScheduledExecutorService scheduler,
long timeout,
TimeUnit unit,
Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
This method will call the given
runAsync function using the common ForkJoinPool with the CompletableFuture
being returned. |
public static <R> CompletableFuture<R> asyncSupply(Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
runAsync
function using the common ForkJoinPool
passing
in a new CompletableFuture
which is also being returned from this method. This future is supposed to be used to checked by
the runAsync
function for completion from the outside. The value returned by the runAsync
function will be used
to try to complete the returned future with. If runAsync
throws a Throwable
, it will be used to complete the
future exceptionally with the thrown object. The result or exception from the runAsync
method will not be obtruded to
the future; if the future is completed from the outside before completion of runAsync
, its result will be ignored.R
- Type of the object supplied by runAsync
, and that is promised to be made available in the
returned future.runAsync
- function to be executed on the common ForkJoinPool
. The
result of this function will be used to complete the CompletableFuture returned by this method.runAsync
. This future
may be cancelled by the user, the runAsync
function is advised to check the future for completion.NullPointerException
- if runAsync
is null
public static <R> CompletableFuture<R> asyncSupply(Executor executor, Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
runAsync
function using the provided executor
. A new CompletableFuture
will be passed to runAsync
and returned by this method. This parameter is supposed to be used by the runAsync
function
to check for completion from the outside. The value returned by the runAsync
function will be used to try to
complete the returned future with. If runAsync
throws a Throwable
, it will be used to try to complete the
future exceptionally with the thrown object. The result or exception from the runAsync
method will not be obtruded to
the future; if the future is completed from the outside before completion of runAsync
, its result will be ignored.R
- Type of the object supplied by runAsync
, and that is promised to be made available in the
returned future.executor
- the executor used to execute runAsync
concurrently.runAsync
- function to be executed using the provided executor
.runAsync
. This future
may be cancelled by the user, the runAsync
function is advised to check the future for completion.NullPointerException
- if runAsync
is null
public static <R> CompletableFuture<R> asyncSupply(long timeout, TimeUnit unit, Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
runAsync
function using the common ForkJoinPool
with the CompletableFuture
being returned. This parameter is supposed to be used to checked by the runAsync
function
for cancellation/completion from the outside. The value returned by the runAsync
function will be used to try to
complete the returned future. If runAsync
throws a Throwable
, it will be used to complete the
future exceptionally with the thrown object. If the runAsync
function does not provide a result value
after the timeout specified via the parameters timeout
and unit
, the returned future will be
completed exceptionally with a TimoutException
. Therefore the runAsync
function is advised to check for completion of the future provided
to it as parameter. If runAsync
returns a value after the CompletableFuture was completed, the result
will not appear in the CompletableFuture.R
- Type of the object supplied by runAsync
, and that is promised to be made available in the
returned future.timeout
- Amount of time after which the returned CompletableFuture
is completed exceptionally, if it was not
completed until then. The unit of the amount of time is specified via parameter unit
.unit
- the time unit of the timeout
parameter.runAsync
- function to be executed on the common ForkJoinPool
. The
result of this function will be used to complete the CompletableFuture returned by this method.runAsync
. This future
may be cancelled by the user, the runAsync
function is advised to check the future for completion.NullPointerException
- if runAsync
is null
public static <R> CompletableFuture<R> asyncSupply(ScheduledExecutorService scheduler, long timeout, TimeUnit unit, Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
runAsync
function using the common ForkJoinPool
with the CompletableFuture
being returned. This parameter is supposed to be used to checked by the runAsync
function
for completion/cancellation from the outside. The value returned by the runAsync
function will be used to try to
complete the returned future. If runAsync
throws a Throwable
, it will be used to complete the
future exceptionally with the thrown object. If the runAsync
function does not provide a result value
after the timeout specified via the parameters timeout
and unit
, the returned future will be
completed exceptionally with a new TimeoutException. For the scheduling of the timeout the given scheduler
will be used. The scheduler will not be
shut down after timeout. The runAsync
function is advised to check for completion of the future provided
to it as parameter. If runAsync
returns a value after the CompletableFuture was cancelled or completed from
the outside, the result will not appear in the CompletableFuture; the result will not be obtruted to the future.R
- Type of the object supplied by runAsync
, and that is promised to be made available in the
returned future.scheduler
- is the executor service used to schedule the exceptional completion after timeout specified via
timeout
and unit
.timeout
- Amount of time after which the returned CompletableFuture
is completed exceptionally, if it was not
completed until then. The unit of the amount of time is specified via parameter unit
.unit
- the time unit of the timeout
parameter.runAsync
- function to be executed on the common ForkJoinPool
. The
result of this function will be used to complete the CompletableFuture returned by this method.runAsync
. This future
may be cancelled by the user, the runAsync
function is advised to check the future for cancellation/completion.public static <R> CompletableFuture<R> asyncSupply(Executor executor, long timeout, TimeUnit unit, Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
runAsync
function using the given executor
.
being returned. This parameter is supposed to be used to checked by the runAsync
function
for completion from the outside. The value returned by the runAsync
function will be used to try to
complete the returned future. If runAsync
throws a Throwable
, it will be used to complete the
future exceptionally with the thrown object. If the runAsync
function does not provide a result value
after the timeout specified via the parameters timeout
and unit
, the returned future will be
completed exceptionally with a new TimeoutException
. For the scheduling of the timeout the given
scheduler
will be used. The scheduler will not be shut down after timeout.
The runAsync
function is advised to check for completion of the future provided
to it as parameter. If runAsync
returns a value after the CompletableFuture was cancelled or completed from
the outside, the result will not appear in the CompletableFuture; the result will not be obtruted to the future.R
- Type of the object supplied by runAsync
, and that is promised to be made available in the
returned future.executor
- is the executor used to run runAsync
asynchronously.timeout
- Amount of time after which the returned CompletableFuture
is completed exceptionally, if it was not
completed until then. The unit of the amount of time is specified via parameter unit
.unit
- the time unit of the timeout
parameter.runAsync
- function to be executed on the common ForkJoinPool
. The
result of this function will be used to complete the CompletableFuture returned by this method.runAsync
. This future
may be cancelled by the user, the runAsync
function is advised to check the future for completion.public static <R> CompletableFuture<R> asyncSupply(Executor executor, ScheduledExecutorService scheduler, long timeout, TimeUnit unit, Functions.Function1<? super CompletableFuture<?>,? extends R> runAsync)
runAsync
function using the given executor
.
being returned. This parameter is supposed to be used to checked by the runAsync
function
for completion from the outside. The value returned by the runAsync
function will be used to try to
complete the returned future. If runAsync
throws a Throwable
, it will be used to complete the
future exceptionally with the thrown object. If the runAsync
function does not provide a result value
after the timeout specified via the parameters timeout
and unit
, the returned future will be
completed exceptionally with a TimeoutException
. Therefore the runAsync
function is advised
to check for completion of the future provided to it as parameter.
If runAsync
returns a value after the CompletableFuture was completed, the result
will not appear in the CompletableFuture.R
- Type of the object supplied by runAsync
, and that is promised to be made available in the
returned future.executor
- is the executor used to run runAsync
asynchronously.scheduler
- is the executor service used to schedule the exceptional completion after timeout specified via
timeout
and unit
.timeout
- Amount of time after which the returned CompletableFuture
is completed exceptionally, if it was not
completed until then. The unit of the amount of time is specified via parameter unit
.unit
- the time unit of the timeout
parameter.runAsync
- function to be executed on the common ForkJoinPool
. The
result of this function will be used to complete the CompletableFuture returned by this method.runAsync
. This future
may be cancelled by the user, the runAsync
function is advised to check the future for completion.public static CompletableFuture<?> asyncRun(Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
asyncRun(Executor,(CompletableFuture<?>)=>void)
with
the common ForkJoinPool
as the executor.runAsync
- the action to execute on the common ForkJoinPool
, to which the returned future is passed.CompletableFuture
which will be completed, after successful execution of runAsync
, or completed
exceptionally if runAsync
throws an exception.asyncRun(Executor,org.eclipse.xtext.xbase.lib.Procedures.Procedure1)
public static CompletableFuture<?> asyncRun(Executor executor, Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
CompletableFuture
and will run the given runAsync
procedure
asynchronously, by calling it on the given executor
, passing the created future to it.
The created future will then be returned from this function.runAsync
procedure completes, the future will be completed with a null
value.
If runAsync
throws an exception, the future will be completed exceptionally with the thrown
exception. Neither the successful, nor the exceptional execution of runAsync
will obtrude the
result value into the future. If the future was completed in runAsync
this result will stay
in the future. However, it is advised to use the future in runAsync
only to check for completion
from the outside.executor
- will be used to execute runAsync
runAsync
- procedure to execute using executor
. The future returned from this method
will be passed to this procedure to allow checking for completion from the outside.runAsync
.public static CompletableFuture<?> asyncRun(long timeout, TimeUnit unit, Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
asyncRun(Executor,long,TimeUnit,(CompletableFuture<?>)=>void)
with
the common ForkJoinPool
as the executor.timeout
- the time in unit
after which the returned future will be completed exceptionally.unit
- the time unit for timeout
.runAsync
- the action to be called on the common ForkJoinPool
. The returned future will be passed to this function on invocation.null
value after successful execution of runAsync
or exceptionally if runAsync
throws an exception.asyncRun(Executor,long,TimeUnit,org.eclipse.xtext.xbase.lib.Procedures.Procedure1)
public static CompletableFuture<?> asyncRun(Executor executor, long timeout, TimeUnit unit, Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
CompletableFuture
and will run the given runAsync
procedure
asynchronously, by calling it on the given executor
, passing the created future to it.
The created future will then be returned from this function.runAsync
procedure completes, the future will be completed with a null
value.
If runAsync
throws an exception, the future will be completed exceptionally with the thrown
exception. If the runAsync
procedure does not finish executing after a timeout defined via
timeout
and unit
, the future will be completed exceptionally with a new TimeoutException
.runAsync
will obtrude the
result value into the future. This includes completion via timeout.
If the future was completed in runAsync
this result will stay in the future.
However, it is advised to use the future in runAsync
only to check for completion from the outside.executor
- will be used to execute runAsync
timeout
- the time in unit
after which the returned future will be completed exceptionally.unit
- the time unit for timeout
.runAsync
- procedure to execute using executor
. The future returned from this method
will be passed to this procedure to allow checking for completion from the outside.runAsync
.public static CompletableFuture<?> asyncRun(Executor executor, ScheduledExecutorService scheduler, long timeout, TimeUnit unit, Procedures.Procedure1<? super CompletableFuture<?>> runAsync)
CompletableFuture
and will run the given runAsync
procedure
asynchronously, by calling it on the given executor
, passing the created future to it.
The created future will then be returned from this function.runAsync
procedure completes, the future will be completed with a null
value.
If runAsync
throws an exception, the future will be completed exceptionally with the thrown
exception. If the runAsync
procedure does not finish executing after a timeout defined via
timeout
and unit
, the future will be completed exceptionally with a new TimeoutException
.
The timeout will be scheduled using the given scheduler
.runAsync
will obtrude the
result value into the future. This includes completion via by timeout.
If the future was completed in runAsync
this result will stay in the future.
However, it is advised to use the future in runAsync
only to check for completion from the outside.executor
- will be used to execute runAsync
.scheduler
- is the executor service used to schedule the exceptional completion after timeout specified via
timeout
and unit
.timeout
- the time in unit
after which the returned future will be completed exceptionally.unit
- the time unit for timeout
.runAsync
- the action to be called on the common ForkJoinPool
. The returned future will be passed to this function on invocation.runAsync
- procedure to execute using executor
. The future returned from this method
will be passed to this procedure to allow checking for completion from the outside.runAsync
.Copyright © 2019. All rights reserved.