Package java.lang.ref

Examples of java.lang.ref.SoftReference


        BreakIterator result = createBreakInstance(locale,
                                                   type,
                                                   dataName,
                                                   dictionaryName);
        BreakIteratorCache cache = new BreakIteratorCache(locale, result);
        iterCache[type] = new SoftReference(cache);
        return result;
    }
View Full Code Here


    private static ThreadLocal encoder = new ThreadLocal();

    private static boolean warnUnsupportedCharset = true;

    private static Object deref(ThreadLocal tl) {
        SoftReference sr = (SoftReference)tl.get();
  if (sr == null)
      return null;
  return sr.get();
    }
View Full Code Here

      return null;
  return sr.get();
    }

    private static void set(ThreadLocal tl, Object ob) {
  tl.set(new SoftReference(ob));
    }
View Full Code Here

     */
    static Reference createReference(Object obj, boolean soft) {
  Reference ref = null;
  if (obj != null) {
      if (soft) {
    ref = new SoftReference(obj);
      } else {
    ref = new WeakReference(obj);
      }
  }
  return ref;
View Full Code Here

  }
  method = findMethod(targetClass, methodName, argClasses);
        if (cache && method != null) {
      if (methodCache == null) {
    methodCache = new HashMap();
    methodCacheRef = new SoftReference(methodCache);
      }
            methodCache.put(signature, method);
        }
        return method;
    }
View Full Code Here

    private static class MyThreadLocal extends ThreadLocal<SoftReference> {

        ConcurrentHashMap<String,AtomicInteger> usage = new ConcurrentHashMap<String,AtomicInteger> ();

        public ThreadCategoryInfo getInfo() {
            final SoftReference reference = get();
            ThreadCategoryInfo tcinfo;
            if (reference != null) {
                tcinfo = (ThreadCategoryInfo) reference.get();
                if( tcinfo == null ) {
                    tcinfo = new ThreadCategoryInfo();
                    set(new SoftReference(tcinfo));
                }
            }
            else {
                tcinfo = new ThreadCategoryInfo();
                set(new SoftReference(tcinfo));
            }
            return tcinfo;
        }
View Full Code Here

            }
            return tcinfo;
        }

        public ThreadCategoryInfo getInfoNullable() {
            final SoftReference reference = get();
            return reference == null ? null : (ThreadCategoryInfo) reference.get();
        }
View Full Code Here

        }
       
        @Override public V call(final Object... args) {
            if (queue.poll() != null) cleanUpNullReferences(cache, queue)// if something has been evicted, do a clean-up
            final Object key = generateKey(args);
            final SoftReference reference = (SoftReference) cache.get(key);
            Object result = reference != null ? reference.get() : null;
            if (result == null) {
                result = closure.call(args);
                if (result == null) {
                    result = MEMOIZE_NULL;
                }
                cache.put(key, new SoftReference(result));
            }
            lruProtectionStorage.touch(key, result);
            return result == MEMOIZE_NULL ? null : (V) result;
        }
View Full Code Here

        int i = 0;
        while ( i < size )
        {
            try
            {
                SoftReference ref = (SoftReference) _pool.get( i );
                buffer = (ByteBuffer) ref.get();
                if ( buffer != null && buffer.capacity() >= capacity )
                {
                    ref.clear();
                    _pool.remove( i );
                    _currentSize -= buffer.capacity();
                    buffer.limit( capacity );
                    LOG.log( Level.FINEST, "Borrowed buffer with capacity of " + buffer.capacity() + "(limit="
                            + capacity + "). Pool max size: " + _sizeB + " Current pool size: " + _currentSize );
View Full Code Here

    {
        clean();
        if ( _currentSize <= _sizeB )
        {
            buffer.clear();
            SoftReference ref = new SoftReference( buffer, this._refQueue );
            _pool.add( ref );
            _currentSize += buffer.capacity();
            LOG.log( Level.FINEST, "Pushed back buffer with capacity of " + buffer.capacity() + ". Pool max size: "
                    + _sizeB + " Current pool size: " + _currentSize );
        }
View Full Code Here

TOP

Related Classes of java.lang.ref.SoftReference

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.