Java Code Examples for java.util.WeakHashMap#isEmpty()

The following examples show how to use java.util.WeakHashMap#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: World.java    From es6draft with MIT License 6 votes vote down vote up
private void enqueueWeakFinalizers() {
    // Clear any strong references.
    WeakHashMap<?, ?> strongRefs = this.reachabilityMap;
    if (!strongRefs.isEmpty()) {
        strongRefs.clear();
    }

    // Enqueue finalizer jobs.
    ReferenceQueue<ScriptObject> weakQueue = this.weakQueue;
    ArrayDeque<Job> finalizerJobs = this.finalizerJobs;
    for (Reference<? extends ScriptObject> ref; (ref = weakQueue.poll()) != null;) {
        Ref<Runnable> finalizer = ((WeakReferenceWithFinalizer) ref).getFinalizer();
        if (finalizer.get() != null) {
            finalizerJobs.add(new FinalizerJob(finalizer));
        }
    }
}
 
Example 2
Source File: Lang_34_ToStringStyle_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * <p>
 * Unregisters the given object.
 * </p>
 *
 * <p>
 * Used by the reflection methods to avoid infinite loops.
 * </p>
 *
 * @param value
 *                  The object to unregister.
 */
static void unregister(Object value) {
    if (value != null) {
        WeakHashMap<Object, Object> m;
        synchronized (ToStringStyle.class) {
            m = REGISTRY.get();
            if (m != null) {
                m.remove(value);
                if (m.isEmpty()) {
                    REGISTRY.remove();
                }
            }
        }
    }
}
 
Example 3
Source File: Lang_34_ToStringStyle_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * <p>
 * Unregisters the given object.
 * </p>
 *
 * <p>
 * Used by the reflection methods to avoid infinite loops.
 * </p>
 *
 * @param value
 *                  The object to unregister.
 */
static void unregister(Object value) {
    if (value != null) {
        WeakHashMap<Object, Object> m;
        synchronized (ToStringStyle.class) {
            m = REGISTRY.get();
            if (m != null) {
                m.remove(value);
                if (m.isEmpty()) {
                    REGISTRY.remove();
                }
            }
        }
    }
}
 
Example 4
Source File: ToStringBuilderStyle.java    From lite-pool with Apache License 2.0 4 votes vote down vote up
static void unregister(Object v) {
    if (v == null) return; WeakHashMap<Object, Object> m = REGISTRY.get();
    if (m == null) return; m.remove(v); if (m.isEmpty()) REGISTRY.remove();
}