Package com.yahoo.jdisc
Class References
- java.lang.Object
-
- com.yahoo.jdisc.References
-
public class References extends Object
Utility class for working withSharedResource
s andResourceReference
s.- Author:
- bakksjo
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceReference
NOOP_REFERENCE
AResourceReference
that does nothing.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceReference
fromResource(SharedResource resource)
-
-
-
Field Detail
-
NOOP_REFERENCE
public static final ResourceReference NOOP_REFERENCE
AResourceReference
that does nothing. Useful for e.g. testing of resource types when reference counting is not the focus.
-
-
Method Detail
-
fromResource
public static ResourceReference fromResource(SharedResource resource)
Returns a
ResourceReference
that invokesSharedResource.release()
onclose
. Useful for treating the "main" reference of aSharedResource
just as any other reference obtained by callingSharedResource.refer()
. Example:final Request request = new Request(...); try (final ResourceReference ref = References.fromResource(request)) { .... } // The request will be released on exit from the try block.
- Parameters:
resource
- The resource to create a ResourceReference for.- Returns:
- a ResourceReference whose close() method will call release() on the given resource.
-
-