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),