File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -79,11 +79,10 @@ type Flags struct {
7979// Multiple calls to Set() do not queue, meaning that only calls to Get() made
8080// *before* a call to Set() will be notified.
8181type SyncableConfig struct {
82- cond * sync.Cond
83- mutex sync.Mutex
84- current string
85- lastRead string
86- initialized bool
82+ cond * sync.Cond
83+ mutex sync.Mutex
84+ current string
85+ lastRead * string
8786}
8887
8988// NewSyncableConfig creates a new SyncableConfig
@@ -107,12 +106,12 @@ func (m *SyncableConfig) Set(value string) {
107106func (m * SyncableConfig ) Get () string {
108107 m .mutex .Lock ()
109108 defer m .mutex .Unlock ()
110- if m .initialized && m .lastRead == m .current {
109+ if m .lastRead != nil && * m .lastRead == m .current {
111110 m .cond .Wait ()
112111 }
113- m . initialized = true
114- m .lastRead = m . current
115- return m .lastRead
112+ val := m . current
113+ m .lastRead = & val
114+ return * m .lastRead
116115}
117116
118117func main () {
You can’t perform that action at this time.
0 commit comments