On Tue, 31 Jan 2023 10:57:58 GMT, Viktor Klang <d...@openjdk.org> wrote:
> I noticed when looking at the code that there was no real need to use a CHM > to perform the tracking of activation in an ordered fashion on > ForEachOrderedTask, but instead a VarHandle can be used, reducing allocations > and indirection. src/java.base/share/classes/java/util/stream/ForEachOps.java line 372: > 370: private Node<T> node; > 371: > 372: @SuppressWarnings("unused") private volatile > ForEachOrderedTask<S, T> next; // Only accessed through the NEXT VarHandle I think the variable can be declared without `volatile` as the operations on the `VarHandle` will determine the memory semantics used regardless? So, the `NEXT.set()` at L431 might also be replaced with `NEXT.setVolatile()` ------------- PR: https://git.openjdk.org/jdk/pull/12320