mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 04:57:37 +03:00
Use custom atomic.Bool, as it is not supported in Go 1.18
This commit is contained in:
parent
88823fca76
commit
a69a31a3bf
2 changed files with 8 additions and 8 deletions
|
@ -6,13 +6,13 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/tests"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
@ -202,7 +202,7 @@ func newFakeFFmpeg(data string) *fakeFFmpeg {
|
|||
type fakeFFmpeg struct {
|
||||
io.Reader
|
||||
lock sync.Mutex
|
||||
closed atomic.Bool
|
||||
closed utils.AtomicBool
|
||||
}
|
||||
|
||||
func (ff *fakeFFmpeg) Start(ctx context.Context, cmd, path string, maxBitRate int) (f io.ReadCloser, err error) {
|
||||
|
@ -216,10 +216,10 @@ func (ff *fakeFFmpeg) Read(p []byte) (n int, err error) {
|
|||
}
|
||||
|
||||
func (ff *fakeFFmpeg) Close() error {
|
||||
ff.closed.Store(true)
|
||||
ff.closed.Set(true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ff *fakeFFmpeg) IsClosed() bool {
|
||||
return ff.closed.Load()
|
||||
return ff.closed.Get()
|
||||
}
|
||||
|
|
|
@ -2,16 +2,16 @@ package utils
|
|||
|
||||
import "sync/atomic"
|
||||
|
||||
type AtomicBool struct{ flag int32 }
|
||||
type AtomicBool struct{ flag uint32 }
|
||||
|
||||
func (b *AtomicBool) Get() bool {
|
||||
return atomic.LoadInt32(&(b.flag)) != 0
|
||||
return atomic.LoadUint32(&(b.flag)) != 0
|
||||
}
|
||||
|
||||
func (b *AtomicBool) Set(value bool) {
|
||||
var i int32 = 0
|
||||
var i uint32 = 0
|
||||
if value {
|
||||
i = 1
|
||||
}
|
||||
atomic.StoreInt32(&(b.flag), i)
|
||||
atomic.StoreUint32(&(b.flag), i)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue