Skip to content

Commit

Permalink
client: fix OnResponse() not getting called when playing / recording (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 28, 2023
1 parent f254503 commit 1e1e10b
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 212 deletions.
12 changes: 6 additions & 6 deletions writer.go → async_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ import (

// 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 writer struct {
type asyncProcessor struct {
running bool
buffer *ringbuffer.RingBuffer

done chan struct{}
}

func (w *writer) allocateBuffer(size int) {
func (w *asyncProcessor) allocateBuffer(size int) {
w.buffer, _ = ringbuffer.New(uint64(size))
}

func (w *writer) start() {
func (w *asyncProcessor) start() {
w.running = true
w.done = make(chan struct{})
go w.run()
}

func (w *writer) stop() {
func (w *asyncProcessor) stop() {
if w.running {
w.buffer.Close()
<-w.done
w.running = false
}
}

func (w *writer) run() {
func (w *asyncProcessor) run() {
defer close(w.done)

for {
Expand All @@ -44,6 +44,6 @@ func (w *writer) run() {
}
}

func (w *writer) queue(cb func()) {
func (w *asyncProcessor) queue(cb func()) {
w.buffer.Push(cb)
}
Loading

0 comments on commit 1e1e10b

Please sign in to comment.