MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / deliver

Method deliver

internal/nodehub/stream.go:91–106  ·  view source on GitHub ↗

deliver 把一帧投递到 frames 通道。投递在 mu 保护下检查 closed,避免向已关闭通道写入。 frames 缓冲不足时阻塞等待消费方,但若同时 Close 触发则立即放弃(done 兜底)。

(f StreamFrame)

Source from the content-addressed store, hash-verified

89// deliver 把一帧投递到 frames 通道。投递在 mu 保护下检查 closed,避免向已关闭通道写入。
90// frames 缓冲不足时阻塞等待消费方,但若同时 Close 触发则立即放弃(done 兜底)。
91func (s *Stream) deliver(f StreamFrame) {
92 s.mu.Lock()
93 if s.closed {
94 s.mu.Unlock()
95 return
96 }
97 // 持锁期间 Close/closeFromHub 不会进入 closeOnce 内部(互斥锁同源),
98 // 但为避免阻塞 dispatch goroutine 导致死锁,发送时释放锁,转而用 done 兜底。
99 frames := s.frames
100 done := s.done
101 s.mu.Unlock()
102 select {
103 case frames <- f:
104 case <-done:
105 }
106}
107
108// streamFramesBuffer 是 Stream.frames 的缓冲容量。日志/traceroute hop 突发可
109// 容忍少量积压;超出时 deliver 会阻塞 hub 的 recv goroutine 等待消费方。

Callers 1

dispatchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected