improve update counter feature for package gdb

This commit is contained in:
John
2020-11-29 22:26:16 +08:00
parent 32101189a2
commit 2b6e6ce28e
3 changed files with 44 additions and 35 deletions

View File

@ -58,15 +58,17 @@ func Test_Limit1(t *testing.T) {
func Test_Limit2(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
wg := sync.WaitGroup{}
array := garray.NewArray(true)
size := 100
pool := grpool.New(1)
var (
wg = sync.WaitGroup{}
array = garray.NewArray(true)
size = 100
pool = grpool.New(1)
)
wg.Add(size)
for i := 0; i < size; i++ {
pool.Add(func() {
defer wg.Done()
array.Append(1)
wg.Done()
})
}
wg.Wait()