Address some race conditions

This commit is contained in:
Dane Everitt
2020-07-19 17:46:39 -07:00
parent 21e58b57a1
commit e28c05ae56
5 changed files with 28 additions and 5 deletions

View File

@@ -54,6 +54,15 @@ func (s *Server) Proc() *ResourceUsage {
return &s.resources
}
// Returns the servers current state.
func (ru *ResourceUsage) getInternalState() string {
ru.mu.RLock()
defer ru.mu.RUnlock()
return ru.State
}
// Sets the new state for the server.
func (ru *ResourceUsage) setInternalState(state string) {
ru.mu.Lock()
ru.State = state