On 19/06/2018 6:01 AM, Doug Lea wrote:
On 06/18/2018 11:22 AM, Martin Buchholz wrote:
Or better, lockField.set in resetLock could instead be setRelease.
Except it is using reflection, not VarHandles. So it could be preceded
with VarHandle.releaseFence(), although it is hard to think of a
scenario in which it could matter.
You mean followed by, not preceded by?
try {
lockField.set(this, new Object());
+ java.lang.invoke.VarHandle.releaseFence();
} catch (IllegalAccessException e) {
throw new Error(e);
}
OK. Followed by is a little better in that it orders any field write
before any write of this, not just the array copy before lock field write.
Hang on! A releasing store does the "release" before the store not after
it. The whole point being if you see the result of the store then you
are guaranteed to see all previous stores. The above can reorder the
lockField store with whatever stores come before it.
David
-----
-Doug