MCPcopy
hub / github.com/panjf2000/ants / TestAntsPoolWithFuncWaitToGetWorkerPreMalloc

Function TestAntsPoolWithFuncWaitToGetWorkerPreMalloc

ants_test.go:138–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestAntsPoolWithFuncWaitToGetWorkerPreMalloc(t *testing.T) {
139 var wg sync.WaitGroup
140 p, _ := ants.NewPoolWithFunc(AntsSize, func(i any) {
141 demoPoolFunc(i)
142 wg.Done()
143 }, ants.WithPreAlloc(true))
144 defer p.Release()
145
146 for i := 0; i < n; i++ {
147 wg.Add(1)
148 _ = p.Invoke(Param)
149 }
150 wg.Wait()
151 t.Logf("pool with func, running workers number:%d", p.Running())
152 mem := runtime.MemStats{}
153 runtime.ReadMemStats(&mem)
154 curMem = mem.TotalAlloc/MiB - curMem
155 t.Logf("memory usage:%d MB", curMem)
156}
157
158func TestAntsPoolWithFuncGenericWaitToGetWorkerPreMalloc(t *testing.T) {
159 var wg sync.WaitGroup

Callers

nothing calls this directly

Calls 4

InvokeMethod · 0.95
demoPoolFuncFunction · 0.85
ReleaseMethod · 0.80
RunningMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…