mirror of
https://github.com/pion/webrtc.git
synced 2025-10-07 08:01:27 +08:00

Add an accessor to make getting value easy. Also add TestPeerConnection_SkipStoppedTransceiver. This commit also cleans up RTPTransceiver creation. We used a helper function, when we should have just used the provide constructor
32 lines
487 B
Go
32 lines
487 B
Go
package webrtc
|
|
|
|
import "sync/atomic"
|
|
|
|
type atomicBool struct {
|
|
val int32
|
|
}
|
|
|
|
func (b *atomicBool) set(value bool) { // nolint: unparam
|
|
var i int32
|
|
if value {
|
|
i = 1
|
|
}
|
|
|
|
atomic.StoreInt32(&b.val, i)
|
|
}
|
|
|
|
func (b *atomicBool) get() bool {
|
|
return atomic.LoadInt32(&b.val) != 0
|
|
}
|
|
|
|
func (b *atomicBool) compareAndSwap(old, new bool) (swapped bool) {
|
|
var oldval, newval int32
|
|
if old {
|
|
oldval = 1
|
|
}
|
|
if new {
|
|
newval = 1
|
|
}
|
|
return atomic.CompareAndSwapInt32(&b.val, oldval, newval)
|
|
}
|