utils.AtomicFlag -> atomic.Bool (#466)

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

* Remove another hand rolled atomic

* utils.AtomicFlag -> atomic.Bool
This commit is contained in:
Raja Subramanian
2022-02-25 12:19:49 +05:30
committed by GitHub
parent 0170cc1cb6
commit 778d1aa141
14 changed files with 83 additions and 85 deletions
+3 -5
View File
@@ -5,8 +5,6 @@ import (
"time"
"go.uber.org/atomic"
"github.com/livekit/protocol/utils"
)
type StreamStatus int32
@@ -54,7 +52,7 @@ type StreamTracker struct {
// only access by the same goroutine as Observe
lastSN uint16
isStopped utils.AtomicFlag
isStopped atomic.Bool
}
func NewStreamTracker(samplesRequired uint32, cyclesRequired uint64, cycleDuration time.Duration) *StreamTracker {
@@ -110,7 +108,7 @@ func (s *StreamTracker) Start() {
}
func (s *StreamTracker) Stop() {
if !s.isStopped.TrySet(true) {
if s.isStopped.Swap(true) {
return
}
@@ -119,7 +117,7 @@ func (s *StreamTracker) Stop() {
}
func (s *StreamTracker) Reset() {
if s.isStopped.Get() {
if s.isStopped.Load() {
return
}