summaryrefslogtreecommitdiff
path: root/changed.go
blob: 3db4a82221b219c15254c8beb885d510876cc219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package config

import (
	"sync"
)

// this provides a trivial way to track which
// protobufs have been modified and need to be written to disk
// todo: autogenpb could generate code to work with this

var saveMap map[string]bool
var saveLock sync.Mutex

func init() {
	// init() should be avoided, but this package and for making
	// this small string map, it seems a sensible exception
	saveMap = make(map[string]bool)
}

func SetChanged(name string, b bool) {
	saveLock.Lock()
	defer saveLock.Unlock()
	saveMap[name] = b
}

func HasChanged(name string) bool {
	return saveMap[name]
}