package main import "sync" // accelStreamCtl tracks which slaves the host wants to poll for accel (mirrors firmware). type accelStreamCtl struct { mu sync.Mutex enabled map[uint32]struct{} } func newAccelStreamCtl() *accelStreamCtl { return &accelStreamCtl{enabled: make(map[uint32]struct{})} } func (c *accelStreamCtl) Set(clientID uint32, on bool) { c.mu.Lock() defer c.mu.Unlock() if on { c.enabled[clientID] = struct{}{} } else { delete(c.enabled, clientID) } } func (c *accelStreamCtl) Any() bool { c.mu.Lock() defer c.mu.Unlock() return len(c.enabled) > 0 } func (c *accelStreamCtl) SyncFromClients(clients []ClientView) { c.mu.Lock() defer c.mu.Unlock() c.enabled = make(map[uint32]struct{}) for _, cl := range clients { if cl.AccelStream { c.enabled[cl.ID] = struct{}{} } } }