1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-20 02:00:49 +00:00
strimertul/modules/http/safebool.go
Ash Keel 0d3233ecbd
Big module refactor
Changing the HTTP config will now restart the server or, if possible, just hotpatch the configuration
2021-11-19 19:37:42 +01:00

26 lines
341 B
Go

package http
import "sync"
type SafeBool struct {
val bool
mux sync.Mutex
}
func newSafeBool(val bool) *SafeBool {
return &SafeBool{val: val, mux: sync.Mutex{}}
}
func (s *SafeBool) Set(val bool) {
s.mux.Lock()
s.val = val
s.mux.Unlock()
}
func (s *SafeBool) Get() bool {
s.mux.Lock()
val := s.val
s.mux.Unlock()
return val
}