public final class PolyglotRuntime extends Object
PolyglotEngine instances. By default a constructed
PolyglotEngine provides data and code isolation. However, if the same runtime is used to
construct multiple engines then code can be shared between them. Languages can also decide to
share immutable parts of their data between engines of a runtime. As a consequence memory
consumption for an engine is expected to be lower if they are constructed with the same runtime.
Methods of PolyglotRuntime can be safely used from multiple-threads.
Usage:
PolyglotRuntimeruntime =PolyglotRuntime.newBuilder(). setOut(out).setErr(err).build();PolyglotEngine.Builderbuilder =PolyglotEngine.newBuilder(). runtime(runtime);PolyglotEngineengine1 = builder.build();PolyglotEngineengine2 = builder.build();PolyglotEngineengine3 = builder.build();
The above example prepares three engines that share the runtime.
PolyglotEngine,
More information for language implementors.| Modifier and Type | Class and Description |
|---|---|
class |
PolyglotRuntime.Builder
Builder for creating new instance of a
PolyglotRuntime. |
class |
PolyglotRuntime.Instrument
A handle for an instrument installed in the runtime,
usable from other threads, that can observe and inject behavior into language execution.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Disposes the runtime and with it all created instruments.
|
Map<String,? extends PolyglotRuntime.Instrument> |
getInstruments()
Gets the map: Instrument ID -->
PolyglotRuntime.Instrument loaded in
this runtime, whether the instrument is
enabled or not. |
static PolyglotRuntime.Builder |
newBuilder()
Starts creation of a new runtime instance.
|
public Map<String,? extends PolyglotRuntime.Instrument> getInstruments()
PolyglotRuntime.Instrument loaded in
this runtime, whether the instrument is
enabled or not.public void dispose()
IllegalStateException if not all engines created using this runtime are not yet
disposed.
Default/private runtimes of an engine
are disposed automatically with the engine.public static PolyglotRuntime.Builder newBuilder()
PolyglotRuntime.Builder and finish
the creation by calling PolyglotRuntime.Builder.build().