Kactoos

kactoos-jvm / nnl.rocks.kactoos.func / Async

Async

class Async<X : Any, Y : Any> : Func<X, Future<Y>>, Proc<X>

Func that runs in the background.

If you want your piece of code to be executed in the background, use Async as following:

int length = new Async(
  input -> input.length()
).invoke("Hello, world!").get();

There is no thread-safety guarantee.

Parameters

X - Type of input

Y - Type of output

func - The func

executor - Executor Service

Since 0.10

Constructors

Name Summary
<init> Async(proc: Proc<X>, result: Y, fct: ThreadFactory)
Async(fnc: Func<X, Y>, fct: ThreadFactory)
Async(fnc: Func<X, Y>)Async(func: Func<X, Y>, executor: ExecutorService)
Func that runs in the background.

Functions

Name Summary
apply fun apply(input: X): Future<Y>
Apply it.
exec fun exec(input: X): Unit
Execute it.