X
- Type of inputY
- Type of outputpublic final class AsyncFunc<X,Y> extends Object implements Func<X,Future<Y>>, Proc<X>
If you want your piece of code to be executed in the background,
use AsyncFunc
as following:
int length = new AsyncFunc( input -> input.length() ).apply("Hello, world!").get();
There is no thread-safety guarantee.
Func.NoNulls<X,Y>
Proc.NoNulls<X>
Constructor and Description |
---|
AsyncFunc(Func<X,Y> fnc)
Ctor.
|
AsyncFunc(Func<X,Y> fnc,
ExecutorService exec)
Ctor.
|
AsyncFunc(Func<X,Y> fnc,
ThreadFactory fct)
Ctor.
|
AsyncFunc(Proc<X> proc)
Ctor.
|
AsyncFunc(Proc<X> proc,
ExecutorService exec)
Ctor.
|
AsyncFunc(Proc<X> proc,
ThreadFactory fct)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
Future<Y> |
apply(X input)
Apply it.
|
void |
exec(X input)
Execute it.
|
public AsyncFunc(Proc<X> proc, ThreadFactory fct)
proc
- The procfct
- Factorypublic AsyncFunc(Func<X,Y> fnc, ThreadFactory fct)
fnc
- The funcfct
- Factorypublic AsyncFunc(Proc<X> proc, ExecutorService exec)
proc
- The procexec
- Executor Servicepublic AsyncFunc(Func<X,Y> fnc, ExecutorService exec)
fnc
- The funcexec
- Executor ServiceCopyright © 2017–2018 Cactoos. All rights reserved.