We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a931be commit fdfff08Copy full SHA for fdfff08
cmd/config-manager/main.go
@@ -82,8 +82,7 @@ type SyncableConfig struct {
82
cond *sync.Cond
83
mutex sync.Mutex
84
current string
85
- lastRead string
86
- initialized bool
+ lastRead *string
87
}
88
89
// NewSyncableConfig creates a new SyncableConfig
@@ -107,12 +106,12 @@ func (m *SyncableConfig) Set(value string) {
107
106
func (m *SyncableConfig) Get() string {
108
m.mutex.Lock()
109
defer m.mutex.Unlock()
110
- if m.initialized && m.lastRead == m.current {
+ if m.lastRead != nil && *m.lastRead == m.current {
111
m.cond.Wait()
112
113
- m.initialized = true
114
- m.lastRead = m.current
115
- return m.lastRead
+ val := m.current
+ m.lastRead = &val
+ return *m.lastRead
116
117
118
func main() {
0 commit comments