Package io.grpc.xds.internal.security
Class ReferenceCountingMap<K,V extends Closeable>
java.lang.Object
io.grpc.xds.internal.security.ReferenceCountingMap<K,V>
- Type Parameters:
K
- Key type for the mapV
- Value type for the map - it should be aCloseable
A map for managing reference-counted shared resources - typically providers.
A key (of generic type K) identifies a provider (of generic type V). The map also depends on a
factory ReferenceCountingMap.ValueFactory
to create a new instance of V as needed. Values are ref-counted and
closed by calling Closeable.close()
when ref-count reaches zero.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
ReferenceCountingMap.Instance<V extends Closeable>
static interface
ReferenceCountingMap.ValueFactory<K,
V extends Closeable> A factory to create a value from the given key. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<K, ReferenceCountingMap.Instance<V>> private final ReferenceCountingMap.ValueFactory
<K, V> -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
instances
-
valueFactory
-
-
Constructor Details
-
ReferenceCountingMap
-
-
Method Details
-
get
Gets an existing instance of a provider. If it doesn't exist, creates a new one using the provided<K, V>
-
release
Releases an instance of the given value.The instance must have been obtained from
get(Object)
. Otherwise will throw IllegalArgumentException.Caller must not release a reference more than once. It's advised that you clear the reference to the instance with the null returned by this method.
- Parameters:
key
- for the instance to be releasedvalue
- the instance to be released- Returns:
- a null which the caller can use to clear the reference to that instance.
-
getInternal
-
releaseInternal
-