Package io.grpc.xds.client
Class ReferenceCounted<T>
- java.lang.Object
-
- io.grpc.xds.client.ReferenceCounted<T>
-
final class ReferenceCounted<T> extends java.lang.Object
A reference count wrapper for objects. This class does not take the ownership for the object, but only provides usage counting. The real owner of the wrapped object is responsible for managing the lifecycle of the object.Intended for a container class to keep track of lifecycle for elements it contains. This wrapper itself should never be returned to the consumers of the elements to avoid reference counts being leaked.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ReferenceCounted(T instance)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) T
get()
(package private) int
getReferenceCount()
(package private) void
release()
(package private) void
retain()
(package private) static <T> ReferenceCounted<T>
wrap(T instance)
-
-
-
Field Detail
-
instance
private final T instance
-
refs
private int refs
-
-
Constructor Detail
-
ReferenceCounted
private ReferenceCounted(T instance)
-
-
Method Detail
-
wrap
static <T> ReferenceCounted<T> wrap(T instance)
-
retain
void retain()
-
release
void release()
-
getReferenceCount
int getReferenceCount()
-
get
T get()
-
-