You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/core/syncx/barrier_test.go

32 lines
491 B
Go

package syncx
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBarrier_Guard(t *testing.T) {
const total = 10000
var barrier Barrier
var count int
for i := 0; i < total; i++ {
barrier.Guard(func() {
count++
})
}
assert.Equal(t, total, count)
}
func TestBarrierPtr_Guard(t *testing.T) {
const total = 10000
barrier := new(Barrier)
var count int
for i := 0; i < total; i++ {
barrier.Guard(func() {
count++
})
}
assert.Equal(t, total, count)
}