Skip to content

Commit be4acc5

Browse files
committed
Refactor to use atomic type
Signed-off-by: cuiweixie <[email protected]>
1 parent 5adb1c3 commit be4acc5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

manager/container.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type containerInfo struct {
6565
}
6666

6767
type containerData struct {
68-
oomEvents uint64
68+
oomEvents atomic.Uint64
6969
handler container.ContainerHandler
7070
info containerInfo
7171
memoryCache *memory.InMemoryCache
@@ -683,7 +683,7 @@ func (cd *containerData) updateStats() error {
683683
}
684684
}
685685

686-
stats.OOMEvents = atomic.LoadUint64(&cd.oomEvents)
686+
stats.OOMEvents = cd.oomEvents.Load()
687687

688688
var customStatsErr error
689689
cm := cd.collectorManager.(*collector.GenericCollectorManager)

manager/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ func (m *manager) watchForNewOoms() error {
12491249
continue
12501250
}
12511251
for _, cont := range conts {
1252-
atomic.AddUint64(&cont.oomEvents, 1)
1252+
cont.oomEvents.Add(1)
12531253
}
12541254
}
12551255
}()

0 commit comments

Comments
 (0)