通用订阅器Helper close 错误修正

添加 通用带超时订阅器
This commit is contained in:
shikong 2023-10-02 23:28:50 +08:00
parent cc4577cc4e
commit 2ab7e9dff5
2 changed files with 18 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;
@ -31,7 +32,7 @@ public interface GenericSubscribe<T> {
public static <T> void delPublisher(Map<String, SubmissionPublisher<T>> publishers, String key){
SubmissionPublisher<T> publisher = publishers.remove(key);
publisher.close();
Optional.ofNullable(publisher).ifPresent(SubmissionPublisher::close);
}
public static <T> void addPublisher(Executor executor, Map<String, SubmissionPublisher<T>> publishers, String key){

View File

@ -0,0 +1,16 @@
package cn.skcks.docking.gb28181.core.sip.message.subscribe;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;
import java.util.concurrent.TimeUnit;
public interface GenericTimeoutSubscribe<T> extends GenericSubscribe<T>{
void addPublisher(String key, long time, TimeUnit timeUnit);
void refreshPublisher(String key, long time, TimeUnit timeUnit);
}