All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.jdisc.ResourceReference Maven / Gradle / Ivy

There is a newer version: 8.410.10
Show newest version
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc;

/**
 * 

Represents a live reference to a {@link SharedResource}. Only provides the ability to release the reference.

* *

Implements {@link 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 */ public interface ResourceReference extends AutoCloseable { /** *

Decrements the reference count of the referenced resource. * You call this method once you are done using an object * that you have previously {@link SharedResource#refer() referred}.

* *

Note that this method is NOT idempotent; you must call it exactly once.

* * @see SharedResource#refer() */ @Override void close(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy