vertx / io.vertx.ext.sync / Sync / awaitResult

awaitResult

@Suspendable open static fun <T : Any> awaitResult(consumer: Consumer<Handler<AsyncResult<T>>>): T

Invoke an asynchronous operation and obtain the result synchronous. The fiber will be blocked until the result is available. No kernel thread is blocked.

Parameters

consumer - this should encapsulate the asynchronous operation. The handler is passed to it.

- the type of the result

Return
the result

@Suspendable open static fun <T : Any> awaitResult(consumer: Consumer<Handler<AsyncResult<T>>>, timeout: Long): T

Invoke an asynchronous operation and obtain the result synchronous. The fiber will be blocked until the result is available. No kernel thread is blocked.

Parameters

consumer - this should encapsulate the asynchronous operation. The handler is passed to it.

timeout - In milliseconds when to cancel the awaited result

- the type of the result

Return
the result or null in case of a time out