From a6f3a49d4d1bc42c785ffd1ffc5016d1ff9fdba6 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 31 Aug 2023 10:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90tick=20=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grpcproto/message.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grpcproto/message.go b/grpcproto/message.go index a1c4b3e..68abfbc 100644 --- a/grpcproto/message.go +++ b/grpcproto/message.go @@ -45,7 +45,7 @@ func RegisterMsgServer(server IMsgServer) { if server.getInterval() > 0 { exitChannel := make(chan bool) serverExitChannelMap[server.getChannelName()] = exitChannel - tick := time.Tick(server.getInterval()) + tick := time.NewTicker(server.getInterval()) go func() { defer func() { if r := recover(); r != nil { @@ -55,9 +55,9 @@ func RegisterMsgServer(server IMsgServer) { }() // 循环推送信息 for { - <-tick + <-tick.C topicMsgs := server.onTick() - if topicMsgs != nil && len(topicMsgs) != 0 { + if len(topicMsgs) != 0 { for _, msg := range topicMsgs { PublishMsg(msg.channalName, msg.data) }