Package java.lang.ref

Examples of java.lang.ref.ReferenceQueue$Lock


      /**now its up to the referencequeue to remove the
       * appropiate obects.
       */
      CacheObject cacheObj = null;
            ReferenceQueue q = cache.getReferenceQueue();
        while ((cacheObj = (CacheObject) q.poll()) != null) {
        cacheObj.resetRefCount();
        tryRemoval(cacheObj);
      }

    } catch (CacheException e) {
View Full Code Here


    /**
     * Test for contains.
     * @throws Exception if any exceptions occur.
     */
    public final void testContains() throws Exception {
        ReferenceQueue q = new ReferenceQueue();
    CacheGroup group = new CacheGroup("testGroup", new AttributesImpl());
    Object obj = new Object();
        group.put("testName", new CacheObject("testName", obj, group, null, q), obj);
    assertEquals(true, group.contains("testName"));
    assertEquals(false, group.contains("testName1"));
View Full Code Here

    public static <V> Closure<V> buildSoftReferenceMemoizeFunction(final int protectedCacheSize, final MemoizeCache<Object, Object> cache, final Closure<V> closure) {
        final ProtectionStorage lruProtectionStorage = protectedCacheSize > 0 ?
                new LRUProtectionStorage(protectedCacheSize) :
                new NullProtectionStorage(); // Nothing should be done when no elements need protection against eviction

        final ReferenceQueue queue = new ReferenceQueue();

        return new SoftReferenceMemoizeFunction<V>(cache, closure, lruProtectionStorage, queue);
    }
View Full Code Here

    {
        this.useCache = useCache;
        if(useCache)
        {
            modelCache = new IdentityHashMap();
            refQueue = new ReferenceQueue();
        }
        else
        {
            modelCache = null;
            refQueue = null;
View Full Code Here

    private final LRUScanMap map;

    Cache(int maxSize)
    {
      map = new LRUScanMap(maxSize);
      refQueue = new ReferenceQueue();
    }
View Full Code Here

            throw new IllegalArgumentException("Load factor must be greater than 0");
        }
        this.loadFactor = loadFactor;
        this.table = new Entry[initialCapacity];
        this.threshold = (int)(initialCapacity * loadFactor);
        this.queue = new ReferenceQueue();
    }
View Full Code Here

    }

    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) {
                if (e.get() == null) {
View Full Code Here

            // Do nothing
        }

        rvm.map = (HashMap)map.clone(); // to preserve initialCapacity, loadFactor
        rvm.map.clear();
        rvm.reaped = new ReferenceQueue();
        rvm.putAll(entrySet());

        return rvm;
    }
View Full Code Here

    long t = Math.min(maxIdleTime, maxLifeTime);

    t = Math.min(config.getInvalidationPeriod(), t);
    if (t == Long.MAX_VALUE) t = -1; // never evict
    if (t >= 0) t = Math.max(100, t); // fixup inefficient parameters
    this.queue = t > 0 ? new ReferenceQueue() : null;
    if (t > 0) SWEEPER.schedule(new SweepTask(this), t, t);
  }
View Full Code Here

         * Construct a <code>TileReaper</code> and make it a daemon.
         */
        TileReaper( LCTileCache tileCache ) {
            super("TileReaper");
            setDaemon( true );
            m_refQ = new ReferenceQueue();
            m_tileCacheRef = new WeakReference( tileCache );
        }
View Full Code Here

TOP

Related Classes of java.lang.ref.ReferenceQueue$Lock

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.