get

Performs a blocking operation on a separate thread, returning a promise for its value.

This method should be used to perform blocking IO, or to perform any operation that synchronously waits for something to happen. The given factory function will be executed on a thread from a special pool for such operations (i.e. not a thread from the main compute event loop).

The operation should do as little computation as possible. It should just perform the blocking operation and immediately return the result. Performing computation during the operation will degrade performance.

on

Blocks execution waiting for this promise to complete and returns the promised value.

This method allows the use of asynchronous API, by synchronous API. This may occur when integrating with other libraries that are not asynchronous. The following example simulates using a library that takes a callback that is expected to produce a value synchronously, but where the production of the value is actually asynchronous.

When this method is called, the promise will be subscribed to on a compute thread while the blocking thread waits. When the promised value has been produced, and the compute thread segment has completed, the value will be returned allowing execution to continue on the blocking thread. The following example visualises this flow by capturing the sequence of events via an ExecInterceptor.