all: Use new Go 1.19 atomic types (#8772)

This commit is contained in:
greatroar
2023-02-07 12:07:34 +01:00
committed by GitHub
parent 882b711958
commit 38f2b34d29
19 changed files with 94 additions and 121 deletions
+3 -9
View File
@@ -134,7 +134,7 @@ type wrapper struct {
subs []Committer
mut sync.Mutex
requiresRestart uint32 // an atomic bool
requiresRestart atomic.Bool
}
// Wrap wraps an existing Configuration structure and ties it to a file on
@@ -340,7 +340,7 @@ func (w *wrapper) notifyListener(sub Committer, from, to Configuration) {
l.Debugln(sub, "committing configuration")
if !sub.CommitConfiguration(from, to) {
l.Debugln(sub, "requires restart")
w.setRequiresRestart()
w.requiresRestart.Store(true)
}
}
@@ -525,13 +525,7 @@ func (w *wrapper) Save() error {
return nil
}
func (w *wrapper) RequiresRestart() bool {
return atomic.LoadUint32(&w.requiresRestart) != 0
}
func (w *wrapper) setRequiresRestart() {
atomic.StoreUint32(&w.requiresRestart, 1)
}
func (w *wrapper) RequiresRestart() bool { return w.requiresRestart.Load() }
type modifyEntry struct {
modifyFunc ModifyFunction