Replace sync/atomic usage with uber/atomic (#471)
This commit is contained in:
@@ -3,12 +3,12 @@ package service_test
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/service"
|
||||
)
|
||||
@@ -77,7 +77,7 @@ func TestRoomLock(t *testing.T) {
|
||||
token, err := rs.LockRoom(ctx, roomName, lockInterval)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, token)
|
||||
unlocked := uint32(0)
|
||||
unlocked := atomic.NewUint32(0)
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
wg.Add(1)
|
||||
@@ -87,12 +87,12 @@ func TestRoomLock(t *testing.T) {
|
||||
token2, err := rs.LockRoom(ctx, roomName, lockInterval)
|
||||
require.NoError(t, err)
|
||||
defer rs.UnlockRoom(ctx, roomName, token2)
|
||||
require.Equal(t, uint32(1), atomic.LoadUint32(&unlocked))
|
||||
require.Equal(t, uint32(1), unlocked.Load())
|
||||
}()
|
||||
|
||||
// release after 2 ms
|
||||
time.Sleep(2 * time.Millisecond)
|
||||
atomic.StoreUint32(&unlocked, 1)
|
||||
unlocked.Store(1)
|
||||
_ = rs.UnlockRoom(ctx, roomName, token)
|
||||
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user