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

Method Tune

ants.go:363–376  ·  view source on GitHub ↗

Tune changes the capacity of this pool, note that it is noneffective to the infinite or pre-allocation pool.

(size int)

Source from the content-addressed store, hash-verified

361
362// Tune changes the capacity of this pool, note that it is noneffective to the infinite or pre-allocation pool.
363func (p *poolCommon) Tune(size int) {
364 capacity := p.Cap()
365 if capacity == -1 || size <= 0 || size == capacity || p.options.PreAlloc {
366 return
367 }
368 atomic.StoreInt32(&p.capacity, int32(size))
369 if size > capacity {
370 if size-capacity == 1 {
371 p.cond.Signal()
372 return
373 }
374 p.cond.Broadcast()
375 }
376}
377
378// IsClosed indicates whether the pool is closed.
379func (p *poolCommon) IsClosed() bool {

Callers 6

TestInfinitePoolFunction · 0.45
TestInfinitePoolWithFuncFunction · 0.45
TestRestCodeCoverageFunction · 0.45
TestPoolTuneScaleUpFunction · 0.45

Calls 1

CapMethod · 0.95

Tested by 6

TestInfinitePoolFunction · 0.36
TestInfinitePoolWithFuncFunction · 0.36
TestRestCodeCoverageFunction · 0.36
TestPoolTuneScaleUpFunction · 0.36