2024-05-15 23:15:00 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-03-10 09:44:48 +00:00
|
|
|
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) swap(value bool) bool {
|
2024-05-15 23:15:00 +00:00
|
|
|
var i int32
|
2022-03-10 09:44:48 +00:00
|
|
|
if value {
|
|
|
|
i = 1
|
|
|
|
}
|
|
|
|
return atomic.SwapInt32(&(b.val), i) != 0
|
|
|
|
}
|