1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-14 17:52:10 -04:00

core: refactor to use a generic-compatible syncmap

This commit is contained in:
bbedward
2025-11-15 19:44:47 -05:00
parent 4cb652abd9
commit 67557555f2
36 changed files with 936 additions and 543 deletions

View File

@@ -148,8 +148,7 @@ func (m *Manager) notifier() {
continue
}
m.subscribers.Range(func(key, value interface{}) bool {
ch := value.(chan CUPSState)
m.subscribers.Range(func(key string, ch chan CUPSState) bool {
select {
case ch <- currentState:
default:
@@ -193,7 +192,7 @@ func (m *Manager) Subscribe(id string) chan CUPSState {
ch := make(chan CUPSState, 64)
wasEmpty := true
m.subscribers.Range(func(key, value interface{}) bool {
m.subscribers.Range(func(key string, ch chan CUPSState) bool {
wasEmpty = false
return false
})
@@ -214,11 +213,11 @@ func (m *Manager) Subscribe(id string) chan CUPSState {
func (m *Manager) Unsubscribe(id string) {
if val, ok := m.subscribers.LoadAndDelete(id); ok {
close(val.(chan CUPSState))
close(val)
}
isEmpty := true
m.subscribers.Range(func(key, value interface{}) bool {
m.subscribers.Range(func(key string, ch chan CUPSState) bool {
isEmpty = false
return false
})
@@ -239,8 +238,7 @@ func (m *Manager) Close() {
m.eventWG.Wait()
m.notifierWg.Wait()
m.subscribers.Range(func(key, value interface{}) bool {
ch := value.(chan CUPSState)
m.subscribers.Range(func(key string, ch chan CUPSState) bool {
close(ch)
m.subscribers.Delete(key)
return true