RFR: Use one future
Alan Bateman
alanb at openjdk.java.net
Fri Apr 15 13:55:56 UTC 2022
On Wed, 13 Apr 2022 23:25:28 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> Here's an example of changing the structured task scope impls, using one `Future` field and comparing future states. In effect the state can only increase monotonically (as per the order determined by the comparator).
>
> The single future field could be made non-volatile, using the `VarHandle` for the volatile read in `handleComplete` since the happens-before edge should ensure the future is visible to the reading thread after `join`.
Clever!
src/jdk.incubator.concurrent/share/classes/jdk/incubator/concurrent/StructuredTaskScope.java line 801:
> 799: }
> 800:
> 801: private static int stateToId(Future.State s) {
Did you mean to to name this stateToId or stateToInt?
Style-wise I guess I'd would align the arrows but it doesn't matter.
-------------
Marked as reviewed by alanb (Committer).
PR: https://git.openjdk.java.net/loom/pull/144
More information about the loom-dev
mailing list