mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
ringbuffer: eliminate idle load by using condition variables instead of sleeps
This commit is contained in:
@@ -42,6 +42,22 @@ func TestPullBeforePush(t *testing.T) {
|
||||
<-done
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
r := New(1024)
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
_, ok := r.Pull()
|
||||
require.Equal(t, false, ok)
|
||||
}()
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
r.Close()
|
||||
<-done
|
||||
}
|
||||
|
||||
func BenchmarkPushPullContinuous(b *testing.B) {
|
||||
r := New(1024 * 8)
|
||||
defer r.Close()
|
||||
|
Reference in New Issue
Block a user