Changes to JEP 453
Attila Kelemen
attila.kelemen85 at gmail.com
Sat May 20 10:48:09 UTC 2023
> - If a STS is used (but not a ShutdownOnXX), after a join(), a task state can return NOT_RUN. As a user how am i suppose to handle that case ? Do a busy loop to wait ?
I will assume you meant RUNNING instead of NOT_RUN, but I was thinking
of the usefulness of the RUNNING state as well (obviously busy wait is
a no go). However, I realized that it can actually be used by a custom
STS implementation, because then a custom policy implementation is
able to wait for the actual termination of the forked `Cancelable`.
The wait it can do this is the following:
1. Override fork, and do something like this there:
```
var endSignal = new CountdownLatch(1);
var subtask = super.fork(() -> {
try {
return task.call();
} finally {
endSignal.countDown();
}
});
if (subtask.state() == Subtask.State.NOT_RUN) {
endSignal.countDown();
}
// At this point `endSignal` is ensured to eventually complete,
// so the policy can use it however it wants.
return subtask;
```
More information about the loom-dev
mailing list