refactor(process): use map for subscribers and drop dead ring buffer

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-03 14:08:20 +08:00
co-authored by Claude
parent 03377eec3c
commit 4a4028486c
2 changed files with 8 additions and 44 deletions
+2 -7
View File
@@ -25,7 +25,7 @@ type Session struct {
Root string
Cmd *exec.Cmd
Stdin io.WriteCloser
Subscribers []Subscription
Subscribers map[Subscription]struct{}
Exit ExitInfo
mu sync.Mutex
}
@@ -35,10 +35,5 @@ type Session struct {
func (s *Session) removeSubscription(sub *subscription) {
s.mu.Lock()
defer s.mu.Unlock()
for i, cur := range s.Subscribers {
if cur == sub {
s.Subscribers = append(s.Subscribers[:i], s.Subscribers[i+1:]...)
return
}
}
delete(s.Subscribers, sub)
}