Class RefCounted<Type>


  • public abstract class RefCounted<Type>
    extends Object
    Keep track of a reference count on a resource and close it when the count hits zero.

    By itself, this class could have some race conditions since there is no synchronization between the refcount check and the close. Solr's use in reference counting searchers is safe since the count can only hit zero if it's unregistered (and hence incref() will not be called again on it).

    • Field Detail

      • resource

        protected final Type resource
    • Constructor Detail

      • RefCounted

        public RefCounted​(Type resource)
    • Method Detail

      • getRefcount

        public int getRefcount()
      • get

        public final Type get()
      • decref

        public void decref()
      • close

        protected abstract void close()