Skip to content

Commit

Permalink
make a better name for once
Browse files Browse the repository at this point in the history
Signed-off-by: hillium <[email protected]>
  • Loading branch information
YuJuncen authored and hawkingrei committed Nov 27, 2024
1 parent 1caabaf commit 8ac1d3f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions br/pkg/storage/locking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func TestConcurrentLock(t *testing.T) {
ch <- struct{}{}
}
}
// sync.OnceFunc holds a `Mutex` during executing `f`...
onceFunc := func(f func()) func() {

asyncOnceFunc := func(f func()) func() {
run := new(atomic.Bool)
return func() {
if run.CompareAndSwap(false, true) {
Expand All @@ -103,9 +103,9 @@ func TestConcurrentLock(t *testing.T) {
}
}
chA := make(chan struct{})
onceA := onceFunc(waitRecvTwice(chA))
onceA := asyncOnceFunc(waitRecvTwice(chA))
chB := make(chan struct{})
onceB := onceFunc(waitRecvTwice(chB))
onceB := asyncOnceFunc(waitRecvTwice(chB))

require.NoError(t, failpoint.EnableCall("github.com/pingcap/tidb/br/pkg/storage/exclusive-write-commit-to-1", onceA))
require.NoError(t, failpoint.EnableCall("github.com/pingcap/tidb/br/pkg/storage/exclusive-write-commit-to-2", onceB))
Expand Down

0 comments on commit 8ac1d3f

Please sign in to comment.