From 41bca1164dbb61f7c0e2d79adec2f53f8070ecfa Mon Sep 17 00:00:00 2001 From: liuxiaobo <1224730913@qq.com> Date: Sat, 7 Jun 2025 23:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=89=A7=E8=A1=8C=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/baseService.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/service/baseService.go b/service/baseService.go index 188e917..c5841b6 100644 --- a/service/baseService.go +++ b/service/baseService.go @@ -8,6 +8,7 @@ import ( "github.com/fox/fox/log" "github.com/fox/fox/safeChan" "github.com/fox/fox/timer" + "sync" "time" ) @@ -15,6 +16,7 @@ type BaseService struct { *timer.Timer type_ string name string + once sync.Once onFunc IOnFunc sender ISender @@ -174,7 +176,9 @@ func (s *BaseService) run() { } func (s *BaseService) Run() { - ksync.GoSafe(s.run, s.Run) + s.once.Do(func() { + ksync.GoSafe(s.run, s.run) + }) } func (s *BaseService) Log(format string, a ...any) string {