From 4d9cb375ec45eb03542b06ad85feac2dd6bba376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 11 Aug 2023 18:18:00 +0800 Subject: [PATCH] =?UTF-8?q?slotCount=E5=92=8Cinterval=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core.go b/core.go index a94998a..415525d 100644 --- a/core.go +++ b/core.go @@ -21,6 +21,14 @@ import ( // // Date : 16:50 2023/8/11 func NewTimeWheel(slotCount int, interval time.Duration) *TimeWheel { + if slotCount <= 0 { + // 默认100个槽位 + slotCount = 100 + } + if interval.Seconds() == 0 { + // 默认60s扫描一次 + interval = time.Second * 60 + } tw := &TimeWheel{ Interval: interval, Slots: make([]*list.List, slotCount),