Interface ResourceReference

All Superinterfaces:
AutoCloseable

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'.
     }
 
Author:
bakksjo
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Decrements the reference count of the referenced resource.
  • Method Details

    • close

      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.

      Specified by:
      close in interface AutoCloseable
      See Also: