Package org.apache.druid.collections
Class ReferenceCountingResourceHolder<T>
java.lang.Object
org.apache.druid.collections.ReferenceCountingResourceHolder<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,ResourceHolder<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Decrements the reference count by 1.static <T extends Closeable>
ReferenceCountingResourceHolder<T>fromCloseable(T object) get()Returns the resource with an initial reference count of 1.Increments the reference count by 1 and returns aResourceHolderrepresenting the new references.static long
-
Constructor Details
-
ReferenceCountingResourceHolder
-
-
Method Details
-
leakedResources
public static long leakedResources() -
fromCloseable
-
get
Returns the resource with an initial reference count of 1. More references can be added by callingincrement().- Specified by:
getin interfaceResourceHolder<T>
-
increment
Increments the reference count by 1 and returns aResourceHolderrepresenting the new references. The returnedResourceHolder"close" method decrements the reference count when the caller no longer needs the resource. ReturnedResourceHolderare not thread-safe. If multiple threads need references to the same resource, they should each call this method on the original object. -
close
public void close()Decrements the reference count by 1. If it reaches to 0, then closescloser.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceResourceHolder<T>
-