mirror of
https://gitee.com/jd-platform-opensource/asyncTool.git
synced 2026-03-22 04:27:15 +08:00
超时时间轮---完成,测试有1ms误差,在找原因
This commit is contained in:
@@ -99,8 +99,11 @@ public class TimeWheel {
|
||||
timerTaskList.addTask(timerTask);
|
||||
if (timerTaskList.setExpiration(virtualId * tickMs)) {
|
||||
//添加到delayList中
|
||||
//TODO 改成加到list对应元素
|
||||
delayList.get(overflowIndex).add(timerTaskList);
|
||||
//TODO 改成加到list对应元素 【20槽, 时间轮层数】,这里添加前一定要初始化到对应层数
|
||||
while (delayList.get(index).size() < overflowIndex + 1) {
|
||||
delayList.get(index).add(timerTaskList);
|
||||
}
|
||||
delayList.get(index).set(overflowIndex, timerTaskList);
|
||||
}
|
||||
} else {
|
||||
//放到上一层的时间轮
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Test {
|
||||
.callback(w)
|
||||
.build();
|
||||
|
||||
workerWrapper.setDelayMs(1002L);
|
||||
workerWrapper.setDelayMs(1003L);
|
||||
|
||||
//虽然尚未执行,但是也可以先取得结果的引用,作为下一个任务的入参。V1.2前写法,需要手工给
|
||||
//V1.3后,不用给wrapper setParam了,直接在worker的action里自行根据id获取即可.参考dependnew包下代码
|
||||
|
||||
Reference in New Issue
Block a user