From ab9b48b08137671a797c4bf3c7afa7b9809c48c2 Mon Sep 17 00:00:00 2001 From: shenkaiwen5 Date: Tue, 16 Nov 2021 11:29:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E8=BD=AE--?= =?UTF-8?q?-=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jd/platform/async/executor/wheel/TimeWheel.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/jd/platform/async/executor/wheel/TimeWheel.java b/src/main/java/com/jd/platform/async/executor/wheel/TimeWheel.java index 11a90a4..e21224c 100644 --- a/src/main/java/com/jd/platform/async/executor/wheel/TimeWheel.java +++ b/src/main/java/com/jd/platform/async/executor/wheel/TimeWheel.java @@ -98,12 +98,11 @@ public class TimeWheel { TimerTaskList timerTaskList = timerTaskLists[index]; timerTaskList.addTask(timerTask); if (timerTaskList.setExpiration(virtualId * tickMs)) { - //添加到delayList中 - //TODO 改成加到list对应元素 【20槽, 时间轮层数】,这里添加前一定要初始化到对应层数 + //加到delayList对应元素 【20槽, 时间轮层数】,这里添加前一定要初始化到对应层数 while (delayList.get(index).size() < overflowIndex + 1) { delayList.get(index).add(new TimerTaskList()); } - //TODO 想办法只设置一次 + //这里每次清空整个槽位的List,并且flush List的元素链表,所以没问题 delayList.get(index).set(overflowIndex, timerTaskList); } } else {