aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf/storewatcher.go
blob: 7a5ab3879337abba302fc0635c18733b6882fe89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* SPDX-License-Identifier: MIT
 *
 * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
 */

package conf

type storeCallback struct {
	cb func()
}

var storeCallbacks = make(map[*storeCallback]bool)

func RegisterStoreChangeCallback(cb func()) *storeCallback {
	startWatchingConfigDir()
	cb()
	s := &storeCallback{cb}
	storeCallbacks[s] = true
	return s
}

func UnregisterStoreChangeCallback(cb *storeCallback) {
	delete(storeCallbacks, cb)
}