From c0dd811f504b00afc3049edb15b3900c6946136d Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 23 Jun 2016 19:20:57 +0300 Subject: [PATCH] Atomically load pool indexes --- pool.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pool.go b/pool.go index 4cfe6a6..e54d8e8 100644 --- a/pool.go +++ b/pool.go @@ -29,7 +29,8 @@ type byteBufferPool struct { } func (p *byteBufferPool) Acquire() *ByteBuffer { - for _, idx := range p.idxs { + for i := 0; i < steps; i++ { + idx := atomic.LoadUint64(&p.idxs[i]) v := p.pools[idx].Get() if v != nil { return v.(*ByteBuffer)