2020-08-28 14:02:51 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2020 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
|
|
|
*
|
2020-10-28 14:38:14 +01:00
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
2020-08-28 14:02:51 +02:00
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2020-11-17 15:38:11 +01:00
|
|
|
package io.netty.buffer.api;
|
2020-07-24 19:38:48 +02:00
|
|
|
|
2020-08-24 16:03:02 +02:00
|
|
|
/**
|
2021-05-26 17:13:29 +02:00
|
|
|
* The Drop interface is used by {@link Resource} instances to implement their resource disposal mechanics.
|
|
|
|
* The {@link #drop(Object)} method will be called by the resource when they are closed.
|
2020-08-24 16:03:02 +02:00
|
|
|
*
|
|
|
|
* @param <T>
|
|
|
|
*/
|
2020-12-10 12:51:18 +01:00
|
|
|
@FunctionalInterface
|
2020-12-08 19:25:53 +01:00
|
|
|
public interface Drop<T> {
|
2020-08-24 16:03:02 +02:00
|
|
|
/**
|
2021-05-26 17:13:29 +02:00
|
|
|
* Dispose of the resources in the given {@link Resource} instance.
|
2020-08-24 16:03:02 +02:00
|
|
|
*
|
2021-05-26 17:13:29 +02:00
|
|
|
* @param obj The {@link Resource} instance being dropped.
|
2020-08-24 16:03:02 +02:00
|
|
|
*/
|
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.
|
|
|
|
*
|
2021-05-26 17:13:29 +02:00
|
|
|
* @param obj The new {@link Resource} instance with the new owner.
|
2020-08-24 16:03:02 +02:00
|
|
|
*/
|
2020-12-10 12:51:18 +01:00
|
|
|
default void attach(T obj) {
|
2020-08-10 12:15:02 +02:00
|
|
|
}
|
2020-07-24 19:38:48 +02:00
|
|
|
}
|