GuestExecutor
Guest Executor
Defines the API surface made available, and expected, for guest execution management; a guest executor is provided for host-side use, in the execution of guest code, which should be background-invoked by a guest runtime.
For example, when using async methods via Node APIs (like the fs
) module, execution of method logic takes place on a GuestExecutor instance, which may manage context switching for the polyglot runtime as needed.
APIs that originate promise objects work this way too, executing on the GuestExecutor when their value is awaited.
Executor Services
Guest executors are, firstly, Executor instances; depending on the implementation assigned, execution may take place in a background thread or in the calling thread (for instance, during testing).
In "production," the executor service is typically multithreaded, and equipped with context lock management.
Coroutine Scope and Context
In addition to the Executor API, the GuestExecutor interface extends CoroutineScope, providing a bridge to the Kotlin Coroutines API.
Co-routine scope may be enclosed to provide context for host-side execution.