Refactor status package to use portbase/runtime.
Refactor the status package to use portbase/runtime and make system status readonly. Also adapts the code base to the new portbase/notifications package.
This commit is contained in:
30
status/state.go
Normal file
30
status/state.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
var (
|
||||
activeLevel = new(uint32)
|
||||
selectedLevel = new(uint32)
|
||||
)
|
||||
|
||||
func setActiveLevel(lvl uint8) {
|
||||
atomic.StoreUint32(activeLevel, uint32(lvl))
|
||||
}
|
||||
|
||||
func setSelectedLevel(lvl uint8) {
|
||||
atomic.StoreUint32(selectedLevel, uint32(lvl))
|
||||
}
|
||||
|
||||
// ActiveSecurityLevel returns the currently active security
|
||||
// level.
|
||||
func ActiveSecurityLevel() uint8 {
|
||||
return uint8(atomic.LoadUint32(activeLevel))
|
||||
}
|
||||
|
||||
// SelectedSecurityLevel returns the security level as selected
|
||||
// by the user.
|
||||
func SelectedSecurityLevel() uint8 {
|
||||
return uint8(atomic.LoadUint32(selectedLevel))
|
||||
}
|
||||
Reference in New Issue
Block a user