From 8acb921ee3cc17ed79a7801f815de49f3d4feda1 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 27 May 2021 13:10:10 +0800 Subject: [PATCH] improve package gtimer for times limitation --- os/gtimer/gtimer_entry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/gtimer/gtimer_entry.go b/os/gtimer/gtimer_entry.go index 1cfca8d62..beebf21a6 100644 --- a/os/gtimer/gtimer_entry.go +++ b/os/gtimer/gtimer_entry.go @@ -33,13 +33,13 @@ func (entry *Entry) Status() int { // Run runs the timer job asynchronously. func (entry *Entry) Run() { leftRunningTimes := entry.times.Add(-1) + // Running times exceeding checks. if leftRunningTimes < 0 { entry.status.Set(StatusClosed) return } // This means it does not limit the running times. - // I know it's ugly, but it is surely high performance for running times limit. - if leftRunningTimes < 2000000000 && leftRunningTimes > 1000000000 { + if leftRunningTimes == math.MaxInt32-1 { entry.times.Set(math.MaxInt32) } go func() {