Skip to content

Commit ce3acb5

Browse files
committed
Add singleContext field to PythonLanguage
1 parent 50893e4 commit ce3acb5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
185185

186186
public final Assumption singleContextAssumption = Truffle.getRuntime().createAssumption("Only a single context is active");
187187

188+
@CompilationFinal private boolean singleContext = true;
189+
190+
public boolean isSingleContext() {
191+
return singleContext;
192+
}
193+
188194
/**
189195
* This assumption will be valid if all contexts are single-threaded. Hence, it will be
190196
* invalidated as soon as at least one context has been initialized for multi-threading.
@@ -727,6 +733,7 @@ private static Source newSource(PythonContext ctxt, SourceBuilder srcBuilder) th
727733
protected void initializeMultipleContexts() {
728734
super.initializeMultipleContexts();
729735
singleContextAssumption.invalidate();
736+
singleContext = false;
730737
}
731738

732739
private final ConcurrentHashMap<String, CallTarget> cachedCode = new ConcurrentHashMap<>();

0 commit comments

Comments
 (0)