Last active
February 4, 2020 12:26
-
-
Save antonu17/ed6fecf89e1dce6cf36e0e08e6836d6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type state struct { | |
sync.RWMutex | |
co2 int | |
temperature float64 | |
} | |
func (s *state) getCo2() int { | |
s.RLock() | |
defer s.RUnlock() | |
return s.co2 | |
} | |
func (s *state) setCo2(co2 int) { | |
s.Lock() | |
defer s.Unlock() | |
s.co2 = co2 | |
} | |
func (s *state) getTemperature() int { | |
s.RLock() | |
defer s.RUnlock() | |
s.temperature | |
} | |
func (s *state) setTemperature(temperature int) { | |
s.Lock() | |
defer s.Unlock() | |
s.temperature = temperature | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment