8314480: Memory ordering spec updates in java.lang.ref

Reviewed-by: dholmes, alanb, darcy
This commit is contained in:
Brent Christian 2024-05-31 21:29:30 +00:00
parent 9fd0e7349e
commit 2cae9a0397
4 changed files with 218 additions and 105 deletions

View file

@ -38,7 +38,7 @@ import java.util.function.Function;
* to run after the cleaner is notified that the object has become
* phantom reachable.
* The cleaner uses {@link PhantomReference} and {@link ReferenceQueue} to be
* notified when the <a href="package-summary.html#reachability">reachability</a>
* notified when the {@linkplain java.lang.ref##reachability reachability}
* changes.
* <p>
* Each cleaner operates independently, managing the pending cleaning actions
@ -215,6 +215,14 @@ public final class Cleaner {
* Refer to the <a href="#compatible-cleaners">API Note</a> above for
* cautions about the behavior of cleaning actions.
*
* <p>The given object is kept strongly reachable (and therefore not eligible
* for cleaning) during the register() method.
*
* <p>{@linkplain java.lang.ref##MemoryConsistency Memory consistency effects}:
* Actions in a thread prior to calling {@code Cleaner.register()}
* <a href="{@docRoot}/java.base/java/util/concurrent/package-summary.html#MemoryVisibility"><i>happen-before</i></a>
* the cleaning action is run by the Cleaner's thread.
*
* @param obj the object to monitor
* @param action a {@code Runnable} to invoke when the object becomes phantom reachable
* @return a {@code Cleanable} instance