< prev index next >
src/java.base/share/classes/java/lang/ref/Reference.java
Print this page
rev 15228 : [mq]: per_review
@@ -142,24 +142,23 @@
/* Atomically get and clear (set to null) the VM's pending list.
*/
private static native Reference<Object> getAndClearReferencePendingList();
- /* Atomically test whether the VM's pending list contains any
- * entries. If not, and await is true, then block until the
- * pending list becomes non-empty. The GC adds references to the
- * pending list and notifies waiting threads when references are
- * added. Returns true when the pending list was found to be
- * non-empty.
+ /* Test whether the VM's pending list contains any entries.
*/
- private static native boolean checkReferencePendingList(boolean await);
+ private static native boolean hasReferencePendingList();
+
+ /* Wait until the VM's pending list may be non-null.
+ */
+ private static native void waitForReferencePendingList();
private static final Object processPendingLock = new Object();
private static boolean processPendingActive = false;
private static void processPendingReferences() {
- checkReferencePendingList(true);
+ waitForReferencePendingList();
Reference<Object> pendingList;
synchronized (processPendingLock) {
pendingList = getAndClearReferencePendingList();
processPendingActive = true;
}
@@ -197,11 +196,11 @@
*/
private static boolean waitForReferenceProcessing()
throws InterruptedException
{
synchronized (processPendingLock) {
- if (processPendingActive || checkReferencePendingList(false)) {
+ if (processPendingActive || hasReferencePendingList()) {
// Wait for progress, not necessarily completion.
processPendingLock.wait();
return true;
} else {
return false;
< prev index next >