mirror of
https://gitee.com/jd-platform-opensource/asyncTool.git
synced 2026-03-22 04:27:15 +08:00
设置单个任务超时时间轮
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package com.jd.platform.async.callback;
|
||||
|
||||
/**
|
||||
* @author wuweifeng wrote on 2019-12-20
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface ITimeoutWorker<T, V> extends IWorker<T, V> {
|
||||
/**
|
||||
* 每个worker都可以设置超时时间
|
||||
* @return 毫秒超时时间
|
||||
*/
|
||||
long timeOut();
|
||||
|
||||
/**
|
||||
* 是否开启单个执行单元的超时功能(有时是一个group设置个超时,而不具备关心单个worker的超时)
|
||||
* <p>注意,如果开启了单个执行单元的超时检测,将使线程池数量多出一倍</p>
|
||||
* @return 是否开启
|
||||
*/
|
||||
boolean enableTimeOut();
|
||||
}
|
||||
@@ -74,10 +74,6 @@ public class WorkerWrapper<T, V> {
|
||||
* 注意,该属性仅在nextWrapper数量<=1时有效,>1时的情况是不存在的
|
||||
*/
|
||||
private volatile boolean needCheckNextWrapperResult = true;
|
||||
/**
|
||||
* 超时时间
|
||||
*/
|
||||
private Long delayMs;
|
||||
|
||||
private static final int FINISH = 1;
|
||||
private static final int ERROR = 2;
|
||||
@@ -629,12 +625,4 @@ public class WorkerWrapper<T, V> {
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
|
||||
public Long getDelayMs() {
|
||||
return delayMs;
|
||||
}
|
||||
|
||||
public void setDelayMs(Long delayMs) {
|
||||
this.delayMs = delayMs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ public class DeWorker implements IWorker<String, User>, ICallback<String, User>
|
||||
return new User("user0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int timeout() {
|
||||
return 75;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User defaultValue() {
|
||||
|
||||
@@ -46,7 +46,6 @@ public class Test {
|
||||
.callback(w)
|
||||
.build();
|
||||
|
||||
workerWrapper.setDelayMs(73L);
|
||||
|
||||
//虽然尚未执行,但是也可以先取得结果的引用,作为下一个任务的入参。V1.2前写法,需要手工给
|
||||
//V1.3后,不用给wrapper setParam了,直接在worker的action里自行根据id获取即可.参考dependnew包下代码
|
||||
|
||||
Reference in New Issue
Block a user