public interface ResourceReference extends AutoCloseable
Represents a live reference to a SharedResource
. Only provides the ability to release the reference.
Implements AutoCloseable
so that it can be used in try-with-resources statements. Example
void doSomethingWithRequest(final Request request) { try (final ResourceReference ref = request.refer()) { // Do something with request } // ref.close() will be called automatically on exit from the try block, releasing the reference on 'request'. }
Modifier and Type | Method and Description |
---|---|
void |
close()
Decrements the reference count of the referenced resource.
|
void close()
Decrements the reference count of the referenced resource.
You call this method once you are done using an object
that you have previously referred
.
Note that this method is NOT idempotent; you must call it exactly once.
close
in interface AutoCloseable
SharedResource.refer()
Copyright © 2017. All rights reserved.