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
+5 -5
View File
@@ -9,10 +9,10 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/pion/interceptor/pkg/cc"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"go.uber.org/atomic"
"github.com/livekit/livekit-server/pkg/config"
)
@@ -153,7 +153,7 @@ type StreamAllocator struct {
eventChMu sync.RWMutex
eventCh chan Event
isStopped utils.AtomicFlag
isStopped atomic.Bool
}
func NewStreamAllocator(params StreamAllocatorParams) *StreamAllocator {
@@ -182,7 +182,7 @@ func (s *StreamAllocator) Start() {
func (s *StreamAllocator) Stop() {
s.eventChMu.Lock()
if !s.isStopped.TrySet(true) {
if s.isStopped.Swap(true) {
s.eventChMu.Unlock()
return
}
@@ -320,7 +320,7 @@ func (s *StreamAllocator) onProbeClusterDone(info ProbeClusterInfo) {
func (s *StreamAllocator) postEvent(event Event) {
s.eventChMu.RLock()
if s.isStopped.Get() {
if s.isStopped.Load() {
s.eventChMu.RUnlock()
return
}
@@ -340,7 +340,7 @@ func (s *StreamAllocator) ping() {
for {
<-ticker.C
if s.isStopped.Get() {
if s.isStopped.Load() {
return
}