From 5e63a2b44672795a6e2a2b0869cbd378fff8ef7c Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Sat, 9 Jun 2018 12:38:41 +0900 Subject: [PATCH] =?UTF-8?q?png=20encoder=20pool=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- image/png_encoder_buf_pool.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 image/png_encoder_buf_pool.go diff --git a/image/png_encoder_buf_pool.go b/image/png_encoder_buf_pool.go new file mode 100644 index 0000000..7d3164d --- /dev/null +++ b/image/png_encoder_buf_pool.go @@ -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) +}