vertx / io.vertx.ext.sync / Sync

Sync

open class Sync

This class contains various static methods to allowing events and asynchronous results to be accessed in a synchronous way.

Author
Tim Fox

Constructors

<init>

Sync()

This class contains various static methods to allowing events and asynchronous results to be accessed in a synchronous way.

Functions

awaitEvent

open static fun <T : Any> awaitEvent(consumer: Consumer<Handler<T>>): T
open static fun <T : Any> awaitEvent(consumer: Consumer<Handler<T>>, timeout: Long): T

Receive a single event from a handler synchronously. The fiber will be blocked until the event occurs. No kernel thread is blocked.

awaitResult

open static fun <T : Any> awaitResult(consumer: Consumer<Handler<AsyncResult<T>>>): T
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.

fiberHandler

open static fun <T : Any> fiberHandler(handler: Handler<T>): Handler<T>

Convert a standard handler to a handler which runs on a fiber. This is necessary if you want to do fiber blocking synchronous operations in your handler.

getContextScheduler

open static fun getContextScheduler(): FiberScheduler

Get the `FiberScheduler` for the current context. There should be only one instance per context.

removeContextScheduler

open static fun removeContextScheduler(): Unit

Remove the scheduler for the current context

streamAdaptor

open static fun <T : Any> streamAdaptor(): HandlerReceiverAdaptor<T>

Create an adaptor that converts a stream of events from a handler into a receiver which allows the events to be received synchronously.

open static fun <T : Any> streamAdaptor(channel: Channel<T>): HandlerReceiverAdaptor<T>

Like #streamAdaptor() but using the specified Quasar `Channel` instance. This is useful if you want to fine-tune the behaviour of the adaptor.