infra
/
goutils
Archived
1
0
Fork 0

png encoder pool 추가

This commit is contained in:
Sangbum Kim 2018-06-09 12:38:41 +09:00
parent 302b7a3ded
commit 5e63a2b446
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package util
import (
"sync"
"image/png"
)
type PNGEncoderBufPool struct {
pool sync.Pool
}
func (p *PNGEncoderBufPool) Get() *png.EncoderBuffer {
v := p.pool.Get()
if v == nil {
return &png.EncoderBuffer{}
}
return v.(*png.EncoderBuffer)
}
func (p *PNGEncoderBufPool) Put(buf *png.EncoderBuffer) {
p.pool.Put(buf)
}