Package java.lang.ref

Examples of java.lang.ref.Reference


    }

    /** Returns canonical instance equivalent to given instance. */
    private static KerberosEndpoint intern(KerberosEndpoint endpoint) {
  synchronized (internTable) {
      Reference ref = (WeakReference) internTable.get(endpoint);
      if (ref != null) {
    KerberosEndpoint canonical = (KerberosEndpoint) ref.get();
    if (canonical != null) {
        return canonical;
    }
      }

View Full Code Here


   * Without an identity-based weak key hash table, we must look up
   * with a key of a weak reference that matches on referent identity.
   * If there is no matching entry, we reuse the same weak reference
   * in the new ImplRef, so register it with our reference queue.
   */
  Reference lookupKey = new WeakKey(impl, reapQueue);
  synchronized (lock) {
      ImplRef implRef = (ImplRef) weakImplTable.get(lookupKey);
      if (implRef == null) {
    implRef = new ImplRef(lookupKey);
    weakImplTable.put(lookupKey, implRef);

    if (reaper == null) {
        reaper = (Thread) AccessController.doPrivileged(
      new NewThreadAction(new Reaper(), "Reaper", true));
        reaper.start();

        /*
         * We are now interested in special assistance from the
         * local garbage collector for aggressively collecting
         * unreachable remote objects, so that they do not keep
         * the VM alive indefinitely.
         *
         * Without guaranteed access to something like the
         * sun.misc.GC API, however, we currently have no
         * practical way of getting such special assistance.
         */
    }
      } else {
    /*
     * Clear the weak reference used for lookup, so that it will
     * not generate spurious reference queue notifications later.
     */
    lookupKey.clear();
      }

      implRef.addTarget(target);
      return implRef;
  }
View Full Code Here

    }

    /*
     * Wait for next cleared weak reference.
     */
    Reference weakRef;
    try {
        weakRef = reapQueue.remove();
    } catch (InterruptedException e) {
        synchronized (lock) {
      interruptible = false;
View Full Code Here

    public Font getFont(final String family, final int style, final int size) {
        collectGarbageInCache();

        String key = family + "-" +  style + "-" + size;

        Reference cr   = (Reference)fontCache.get(key);
        Font      font = null;
        if (cr != null) {
            font = (Font)cr.get();
        }

        if (font == null) {
            font = new Font(family, style, size);
            fontCache.put(key, new CacheReference(key, font, queue));
View Full Code Here

    private SmallAttributeSet
        cacheAttributeSet(final AttributeSet aSet) {

        collectGarbageInCache();

        Reference r = (Reference)cache.get(aSet);
        SmallAttributeSet as = null;
        if (r != null) {
            as = (SmallAttributeSet)r.get();
        }

        if (as == null) {
            as = createSmallAttributeSet(aSet);
            cache.put(as, new WeakReference(as));
View Full Code Here

        if (val == null)
            return true;

        if (!(val instanceof Reference))
            return false;
        Reference ref = (Reference)val;
        val = ref.get();
        if (val == null)
            return true;
        if (val instanceof BufferedImage)
            return true;
View Full Code Here

        if (val == null)
            return true;

        if (!(val instanceof Reference))
            return false;
        Reference ref = (Reference)val;
        val = ref.get();
        if (val == null)
            return true;
        if (val instanceof BufferedImage)
            return true;
View Full Code Here

    }

    public void run() {
        while(true) {
            try {
                Reference ref;
                try {
                    ref = queue.remove();
                    // System.err.println("Cleaned: " + ref);
                } catch (InterruptedException ie) {
                    continue;
View Full Code Here

     * care must be taken if, for instance, you want stale
     * mappings to be removed on a periodic basis by some
     * background thread.
     */
    protected void purge() {
        Reference ref = queue.poll();
        while (ref != null) {
            purge(ref);
            ref = queue.poll();
        }
    }
View Full Code Here

     * care must be taken if, for instance, you want stale
     * mappings to be removed on a periodic basis by some
     * background thread.
     */
    private void purge() {
        Reference ref = queue.poll();
        while (ref != null) {
            purge(ref);
            ref = queue.poll();
        }
    }
View Full Code Here

TOP

Related Classes of java.lang.ref.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.