From 990de84391f1883242d01c81208a74db23e9e915 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 2 Oct 2024 14:34:38 +0800 Subject: [PATCH] chore: better atomic using --- tunnel/statistic/manager.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tunnel/statistic/manager.go b/tunnel/statistic/manager.go index 087471184..0b3092992 100644 --- a/tunnel/statistic/manager.go +++ b/tunnel/statistic/manager.go @@ -114,10 +114,8 @@ func (m *Manager) handle() { ticker := time.NewTicker(time.Second) for range ticker.C { - m.uploadBlip.Store(m.uploadTemp.Load()) - m.uploadTemp.Store(0) - m.downloadBlip.Store(m.downloadTemp.Load()) - m.downloadTemp.Store(0) + m.uploadBlip.Store(m.uploadTemp.Swap(0)) + m.downloadBlip.Store(m.downloadTemp.Swap(0)) } }