Skip to content

Commit 9a810ea

Browse files
committed
minor method name cleanup in PythonContext.ChildContextData
1 parent 37f7455 commit 9a810ea

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MultiprocessingModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Object terminate(long id, PInt sig) {
245245
PythonContext.ChildContextData data = language.getChildContextData(convertTid(id));
246246
try {
247247
data.awaitRunning();
248-
TruffleContext truffleCtx = data.getCtx();
248+
TruffleContext truffleCtx = data.getTruffleContext();
249249
if (!truffleCtx.isCancelling() && data.compareAndSetExiting(false, true)) {
250250
LOGGER.fine("terminating spawned thread");
251251
data.setExitCode(sig.intValue());

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ public Thread getOwner() {
473473

474474
public static final class ChildContextData {
475475
private int exitCode = 0;
476-
private TruffleContext ctx;
477-
private PythonContext parentCtx;
476+
@CompilationFinal private TruffleContext ctx;
477+
@CompilationFinal private PythonContext parentCtx;
478478

479479
private final AtomicBoolean exiting = new AtomicBoolean(false);
480480
private final CountDownLatch running = new CountDownLatch(1);
@@ -487,10 +487,20 @@ public int getExitCode() {
487487
return this.exitCode;
488488
}
489489

490-
public TruffleContext getCtx() {
490+
private void setTruffleContext(TruffleContext ctx) {
491+
assert this.ctx == null;
492+
this.ctx = ctx;
493+
}
494+
495+
public TruffleContext getTruffleContext() {
491496
return ctx;
492497
}
493498

499+
private void setParentContext(PythonContext parentCtx) {
500+
assert this.parentCtx == null;
501+
this.parentCtx = parentCtx;
502+
}
503+
494504
public void awaitRunning() throws InterruptedException {
495505
running.await();
496506
}
@@ -537,9 +547,9 @@ public ChildContextData getChildContextData() {
537547
public long spawnTruffleContext(int fd, int sentinel, int[] fdsToKeep) {
538548
ChildContextData data = new ChildContextData();
539549
if (!isChildContext()) {
540-
data.parentCtx = this;
550+
data.setParentContext(this);
541551
} else {
542-
data.parentCtx = childContextData.parentCtx;
552+
data.setParentContext(childContextData.parentCtx);
543553
}
544554

545555
Builder builder = data.parentCtx.env.newContextBuilder().config(PythonContext.CHILD_CONTEXT_DATA, data);
@@ -597,7 +607,7 @@ public void run() {
597607
try {
598608
LOGGER.fine("starting spawned child context");
599609
TruffleContext ctx = builder.build();
600-
data.ctx = ctx;
610+
data.setTruffleContext(ctx);
601611
Object parent = ctx.enter(null);
602612
try {
603613
Source source = Source.newBuilder(PythonLanguage.ID,

0 commit comments

Comments
 (0)