2020-07-24 19:38:48 +02:00
|
|
|
package io.netty.buffer.b2;
|
|
|
|
|
2020-08-10 12:15:02 +02:00
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
2020-08-24 16:03:02 +02:00
|
|
|
/**
|
|
|
|
* The Drop interface is used by {@link Rc} instances to implement their resource disposal mechanics. The {@link
|
|
|
|
* #drop(Rc)} method will be called by the Rc when their last reference is closed.
|
|
|
|
*
|
|
|
|
* @param <T>
|
|
|
|
*/
|
2020-07-24 19:38:48 +02:00
|
|
|
@FunctionalInterface
|
2020-08-10 12:15:02 +02:00
|
|
|
public interface Drop<T extends Rc<T>> extends Consumer<T> {
|
2020-08-24 16:03:02 +02:00
|
|
|
/**
|
|
|
|
* Dispose of the resources in the given Rc.
|
|
|
|
*
|
|
|
|
* @param obj The Rc instance being dropped.
|
|
|
|
*/
|
2020-07-24 19:38:48 +02:00
|
|
|
void drop(T obj);
|
2020-08-10 12:15:02 +02:00
|
|
|
|
2020-08-24 16:03:02 +02:00
|
|
|
/**
|
|
|
|
* Called when the resource changes owner.
|
|
|
|
*
|
|
|
|
* @param obj The new Rc instance with the new owner.
|
|
|
|
*/
|
2020-08-10 12:15:02 +02:00
|
|
|
@Override
|
2020-08-24 16:03:02 +02:00
|
|
|
default void accept(T obj) {
|
2020-08-10 12:15:02 +02:00
|
|
|
}
|
2020-07-24 19:38:48 +02:00
|
|
|
}
|