Replacing hand rolled ion-sfu atomic with uber/atomic (#465)

* Replacing hand rolled ion-sfu atomic with uber/atomic

* Remove another hand rolled atomic
This commit is contained in:
Raja Subramanian
2022-02-25 11:57:09 +05:30
committed by GitHub
parent 2959eebca8
commit 5a4181b581
11 changed files with 90 additions and 150 deletions
+5 -4
View File
@@ -2,12 +2,13 @@ package buffer
import (
"io"
"sync/atomic"
"go.uber.org/atomic"
)
type RTCPReader struct {
ssrc uint32
closed atomicBool
closed atomic.Bool
onPacket atomic.Value // func([]byte)
onClose func()
}
@@ -17,7 +18,7 @@ func NewRTCPReader(ssrc uint32) *RTCPReader {
}
func (r *RTCPReader) Write(p []byte) (n int, err error) {
if r.closed.get() {
if r.closed.Load() {
err = io.EOF
return
}
@@ -32,7 +33,7 @@ func (r *RTCPReader) OnClose(fn func()) {
}
func (r *RTCPReader) Close() error {
r.closed.set(true)
r.closed.Store(true)
r.onClose()
return nil
}