RuntimeContext
Runtime Context
Offers a public API for obtaining the current EngineContextAPI from within an engine thread, and APIs for switching to an exclusive engine-owned execution context.
Truffle engines are not always capable of multi-threading: engines like JavaScript must be confined to one execution thread at a time. Elide's execution model involves multiple contexts which are managed by the engine. To facilitate thread safety under this model, a dedicated polyglot org.graalvm.polyglot.Context is created for each "engine thread," and that thread entirely owns execution for the duration of its lifetime.
Execution tasks are scheduled on the engine thread by enqueueing a task to the "guest executor," which is aware of the engine's execution context.
Functions
Provide the engine context object for the current thread; if the current thread is not an engine thread with an assigned context, null
is returned.
Provide the engine context object for the current thread; if the current thread is not an engine thread with an assigned context, an error is thrown.
Provide the engine executor, initializing it lazily if needed; the executor can safely accept tasks which are sent to a pool of engine threads.
Indicate whether we are currently executing on an engine thread.