代码拉取完成,页面将自动刷新
package gortsplib
import (
"github.com/bluenviron/gortsplib/v4/pkg/ringbuffer"
)
// this struct contains a queue that allows to detach the routine that is reading a stream
// from the routine that is writing a stream.
type asyncProcessor struct {
running bool
buffer *ringbuffer.RingBuffer
done chan struct{}
}
func (w *asyncProcessor) allocateBuffer(size int) {
w.buffer, _ = ringbuffer.New(uint64(size))
}
func (w *asyncProcessor) start() {
w.running = true
w.done = make(chan struct{})
go w.run()
}
func (w *asyncProcessor) stop() {
if w.running {
w.buffer.Close()
<-w.done
w.running = false
}
}
func (w *asyncProcessor) run() {
defer close(w.done)
for {
tmp, ok := w.buffer.Pull()
if !ok {
return
}
tmp.(func())()
}
}
func (w *asyncProcessor) push(cb func()) bool {
return w.buffer.Push(cb)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。