-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
-
None
The "Inheritance" section of j.l.ScopedValue contains the following sample
(DRAFT 21-ea+27-LTS-2343)
https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.html#inheritance
====
private static final ScopedValue<String> NAME = ScopedValue.newInstance();
ScopedValue.runWhere(NAME, "duke", () -> {
try (var scope = new StructuredTaskScope<String>()) {
scope.fork(() -> childTask1());
scope.fork(() -> childTask2());
scope.fork(() -> childTask3());
...
}
});
====
The example basically does not work out-of-the-box - it is missing scope.join(); after forking, otherwise the result would be
java.lang.IllegalStateException: Owner did not join after forking subtasks
UPDATE: and the thrown java.lang.IllegalStateException is not mentioned anywhere in the specs for j.l.ScopedValue+Carrier classes
(DRAFT 21-ea+27-LTS-2343)
https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.html#inheritance
====
private static final ScopedValue<String> NAME = ScopedValue.newInstance();
ScopedValue.runWhere(NAME, "duke", () -> {
try (var scope = new StructuredTaskScope<String>()) {
scope.fork(() -> childTask1());
scope.fork(() -> childTask2());
scope.fork(() -> childTask3());
...
}
});
====
The example basically does not work out-of-the-box - it is missing scope.join(); after forking, otherwise the result would be
java.lang.IllegalStateException: Owner did not join after forking subtasks
UPDATE: and the thrown java.lang.IllegalStateException is not mentioned anywhere in the specs for j.l.ScopedValue+Carrier classes