Cleanup logic for updating stats to avoid calling mutex outside of file

This commit is contained in:
Dane Everitt
2022-01-30 11:55:59 -05:00
parent d7c7155802
commit 57daf0889a
2 changed files with 10 additions and 6 deletions

View File

@@ -38,6 +38,13 @@ func (s *Server) Proc() ResourceUsage {
return s.resources
}
// UpdateStats updates the current stats for the server's resource usage.
func (ru *ResourceUsage) UpdateStats(stats environment.Stats) {
ru.mu.Lock()
ru.Stats = stats
ru.mu.Unlock()
}
// Reset resets the usages values to zero, used when a server is stopped to ensure we don't hold
// onto any values incorrectly.
func (ru *ResourceUsage) Reset() {