From e49563d35acab84fc5cf719dc3822d4dbfadd5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Sat, 25 Mar 2023 07:29:33 +0000 Subject: [PATCH] fix: fix idling for high cpu usage --- internal/app/api/service/bilbil_picture.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/app/api/service/bilbil_picture.go b/internal/app/api/service/bilbil_picture.go index 529e28a..0454a7f 100644 --- a/internal/app/api/service/bilbil_picture.go +++ b/internal/app/api/service/bilbil_picture.go @@ -54,13 +54,16 @@ func (c *RandomPicsCache) Run() error { c.flush() }() go func(_tk *time.Ticker) { - for { - select { - case <-_tk.C: - c.flush() - default: - continue - } +// for { +// select { +// case <-_tk.C: +// c.flush() +// default: +// continue +// } +// } + for _ = range _tk.C { + c.flush() } }(tk) return nil