Package java.lang.ref

Examples of java.lang.ref.Reference


         * (if any).
         */
        public void run() {
            while ( !m_killed ) {
                try {
                    final Reference weakKey = m_refQ.remove(); // Image to be garbage collected

                    final LCTileCache tileCache =
                        (LCTileCache) m_tileCacheRef.get();

                    if ( tileCache == null )
View Full Code Here


        throw new UnsupportedOperationException();
    }

    public Object get( Object key ) {
        Object value = null;
        final Reference valueRef = (Reference)m_map.get( key );
        if ( valueRef != null ) {
            value = valueRef.get();
            if ( value == null )
                m_map.remove( key );
        }
        return value;
    }
View Full Code Here

    }

    public Object put( Object key, Object value ) {
        processQueue();
        final Object newValueRef = new ValueReference( key, value, m_refQueue );
        final Reference oldValueRef = (Reference)m_map.put( key, newValueRef );
        return oldValueRef != null ? oldValueRef.get() : null;
    }
View Full Code Here

 
  @SuppressWarnings("rawtypes")
  private void cleanupCache() {
    Set<CacheKeyWrapper> toCleanup = new HashSet<>();
    synchronized (queue) {
      Reference cleared = null;
      do {
        cleared = queue.poll();
        if (cleared != null) {
          if (cleared instanceof KeySoftReference<?>) {
            toCleanup.add(new CacheKeyWrapper(((KeySoftReference<?>)cleared).key));
View Full Code Here

       
        synchronized (REFERENCE_TO_CONNECTION_SOURCE) {
           
            Iterator referenceIter = REFERENCE_TO_CONNECTION_SOURCE.keySet().iterator();
            while (referenceIter.hasNext()) {
                Reference ref = (Reference) referenceIter.next();
                ConnectionSource source =
                    (ConnectionSource) REFERENCE_TO_CONNECTION_SOURCE.get(ref);
                if (source.connectionPool == connectionPool) {
                    referenceIter.remove();
                    HttpConnection connection = (HttpConnection) ref.get();
                    if (connection != null) {
                        connectionsToClose.add(connection);
                    }
                }
            }
View Full Code Here

            while (!shutdown) {
                try {
                    // remove the next reference and process it, a timeout
                    // is used so that the thread does not block indefinitely
                    // and therefore keep the thread from shutting down
                    Reference ref = REFERENCE_QUEUE.remove(1000);
                    if (ref != null) {
                        handleReference(ref);
                    }
                } catch (InterruptedException e) {
                    LOG.debug("ReferenceQueueThread interrupted", e);
View Full Code Here

         * Start execution.
         */
        public void run() {
            while (true) {
                try {
                    Reference ref = referenceQueue.remove();
                    if (ref != null) {
                        handleReference(ref);
                    }
                } catch (InterruptedException e) {
                    LOG.debug("ReferenceQueueThread interrupted", e);
View Full Code Here

   
    /**
     * Removes stale entries from the pool.
     */
    private void clean() {
        Reference ref = fReferenceQueue.poll();
        while (ref != null) {
            Entry entry = ((SoftGrammarReference) ref).entry;
            if (entry != null) {
                removeEntry(entry);
            }
View Full Code Here

   
    /**
     * Remove stale references from the given list.
     */
    private void removeStaleReferences(ReferenceQueue queue, List list) {
        Reference ref = queue.poll();
        int count = 0;
        while (ref != null) {
            ++count;
            ref = queue.poll();
        }
View Full Code Here

     * @param md The method descriptor
     * @return The cached method
     */
    private static Method getCachedMethod(MethodDescriptor md) {
        if (CACHE_METHODS) {
            Reference methodRef = (Reference)cache.get(md);
            if (methodRef != null) {
                return (Method)methodRef.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.