Package java.lang.ref

Examples of java.lang.ref.Reference


    private void cleanup() {
        // Cleanup after cleared References.
        Entry[] tab = this.table;
        ReferenceQueue queue = this.queue;
        Reference ref;
        while ((ref = queue.poll()) != null) {
            // Since buckets are single-linked, traverse entire list and
            // cleanup all cleared references in it.
            int index = (((Entry) ref).hash & 0x7fffffff) % tab.length;
            for (Entry e = tab[index], prev = null; e != null; e = e.next) {
View Full Code Here


      log.debug("putFile: " + file.getName());
    }

    Map files = getOrCreateFilesystemCache(file.getFileSystem());

    Reference ref = new SoftReference(file, refqueue);
    FileSystemAndNameKey key = new FileSystemAndNameKey(file
        .getFileSystem(), file.getName());

    synchronized (files)
    {
View Full Code Here

    {
      loop: while (!requestEnd && !Thread.currentThread().isInterrupted())
      {
        try
        {
          Reference ref = refqueue.remove(1000);
          if (ref == null)
          {
            continue;
          }
View Full Code Here

     * @return The Value
     **/
    public Object get(Object key)
    {
        reap();
        Reference ref = (Reference)map.get(key);

        Object value = ref == null ? null : ref.get();

        return value;
    }
View Full Code Here

        {
            Iterator i = map.values().iterator();

            while (i.hasNext())
            {
                Reference ref = (Reference)i.next();

                if (obj.equals(ref.get()))
                {
                    return true;
                }
            }
        }
View Full Code Here

        Iterator i = c.iterator();
        ArrayList l = new ArrayList(c.size());

        while (i.hasNext())
        {
            Reference ref = (Reference)i.next();
            Object obj = ref.get();

            if (obj != null)
            {
                l.add(obj);
            }
View Full Code Here

        HashMap m = new HashMap(s.size());

        while (i.hasNext())
        {
            Map.Entry entry = (Map.Entry)i.next();
            Reference ref = (Reference)entry.getValue();
            Object obj = ref.get();

            if (obj != null)
            {
                m.put(entry.getKey(), obj);
            }
View Full Code Here

     */
    public Object getObject(Object key)
    {

        Object    result = null;
        Reference ref    = null;

        ref = (Reference) cache.getObject(key);

        if (ref != null)
        {
            result = ref.get();

            if (result == null)
            {
                LOG.debug("reference found in cache but GC removed object");
                cache.remove(key);
View Full Code Here

     * Cleans all cache elements out that have had their objects collected by the GC.
     */
    public synchronized void removeExpiredElements()
    {

        Reference ref         = null;
        Object    key         = null;
        int       removeCount = 0;

        while ((ref = referenceQueue.poll()) != null)
        {
View Full Code Here

                // Update the unpinned cache otherwise
                obj = unpinnedCache.put(oid, pc);
                if (obj != null)
                {
                    // Values in a WeakRefCache are of type Reference
                    Reference ref = (Reference)obj;
                    return (CachedPC)ref.get();
                }
            }
        }

        return null;
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.