threads as means to an end, rather than parts of a whole
John Rose
john.r.rose at oracle.com
Fri May 21 23:25:02 UTC 2021
On May 21, 2021, at 3:26 PM, John Rose <john.r.rose at oracle.com<mailto:john.r.rose at oracle.com>> wrote:
So here’s a very rough and incomplete cut to show some possibilities:
interface /*Thread*/Destination<W /*extends Thread*/> { // joins void
...static Destination<?> nextDestination(Destination<?> dest); }
Reminder: I’m not a Loom developer or even a thread expert. I’d be
shocked to see the above API actually built.
P.P.S. I was also shocked to see what misuse of the Emacs auto-fill
command did to that code. Here’s the proper formatting:
interface /*Thread*/Destination<W /*extends Thread*/> {
// joins
void waitFor(W worker);
void waitForAll();
// cancellation
void cancel(W worker);
void cancelAll();
// delivery of results (executed inside W, perhaps?)
void notifyCompleted(W worker, Object answer);
void notifyCompletedExceptionally(W worker, Throwable exception);
// advanced: transfers and delegation (probably needs a broker API)
void transferOut(W worker, Destination<? super W> newDestination);
void transferOutAll(Destination<? super W> newDestination);
}
// debugging, reflection, internal management class
jdk.internal.DestinationUtils {
// classification and discovery, mainly for debugging:
static boolean isWorker(Destination<?> dest, Object possibleWorker);
static Stream<Object> findWorkers(Destination<?> dest, float howHardToSearch);
static findWorkers(Destination<?> dest, float howHardToSearch);
// structure (in case this is not a final destination, but a means to a larger end)
static Destination<?> nextDestination(Destination<?> dest);
}
More information about the loom-dev
mailing list