We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s.ws.Range(func(key, val interface{}) bool { v := val.(*PackWriterCloser) fmt.Printf(key.(string) + "\n") if !v.init { if err = s.cache.Send(v.w); err != nil { log.Debugf("[%s] send cache packet error: %v, remove", v.w.Info(), err) s.ws.Delete(key) return true } fmt.Printf("key:%v, value:%v", key, val) v.init = true } else { newPacket := p if err = v.w.Write(&newPacket); err != nil { log.Debugf("[%s] write packet error: %v, remove", v.w.Info(), err) s.ws.Delete(key) } } return true }) 上述代码遍历了某个推流stream下的ws(sync.map),循环向每个想要拉流的tcp连接写入av.Packet,如此一来在连接数很多时是否会导致效率极低,甚至影响推流写入cache的速度,在多人直播间中应该如何优化呢,也可能是本人理解错误了,希望大佬帮忙回答下,感谢
The text was updated successfully, but these errors were encountered:
v.w.Write的逻辑本质上是写入到一个chan里面,如果chan满了会做丢包处理,所以代码层面上这里本身不会引起阻塞从而有性能问题
Sorry, something went wrong.
No branches or pull requests
s.ws.Range(func(key, val interface{}) bool {
v := val.(*PackWriterCloser)
fmt.Printf(key.(string) + "\n")
if !v.init {
if err = s.cache.Send(v.w); err != nil {
log.Debugf("[%s] send cache packet error: %v, remove", v.w.Info(), err)
s.ws.Delete(key)
return true
}
fmt.Printf("key:%v, value:%v", key, val)
v.init = true
} else {
newPacket := p
if err = v.w.Write(&newPacket); err != nil {
log.Debugf("[%s] write packet error: %v, remove", v.w.Info(), err)
s.ws.Delete(key)
}
}
return true
})
上述代码遍历了某个推流stream下的ws(sync.map),循环向每个想要拉流的tcp连接写入av.Packet,如此一来在连接数很多时是否会导致效率极低,甚至影响推流写入cache的速度,在多人直播间中应该如何优化呢,也可能是本人理解错误了,希望大佬帮忙回答下,感谢
The text was updated successfully, but these errors were encountered: