Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cmd/config-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type SyncableConfig struct {
cond *sync.Cond
mutex sync.Mutex
current string
lastRead string
lastRead *string
}

// NewSyncableConfig creates a new SyncableConfig
Expand All @@ -106,11 +106,12 @@ func (m *SyncableConfig) Set(value string) {
func (m *SyncableConfig) Get() string {
m.mutex.Lock()
defer m.mutex.Unlock()
if m.lastRead == m.current {
if m.lastRead != nil && *m.lastRead == m.current {
m.cond.Wait()
}
m.lastRead = m.current
return m.lastRead
val := m.current
m.lastRead = &val
return *m.lastRead
}

func main() {
Expand Down