File: pool.go

package info (click to toggle)
golang-github-meilisearch-meilisearch-go 0.33.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: makefile: 9
file content (21 lines) | stat: -rw-r--r-- 285 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package meilisearch

import (
	"bytes"
	"sync"
)

type pooledBuffer struct {
	*bytes.Buffer
	pool *sync.Pool
}

func (pb *pooledBuffer) Read(p []byte) (int, error) {
	return pb.Buffer.Read(p)
}

func (pb *pooledBuffer) Close() error {
	pb.Reset()
	pb.pool.Put(pb.Buffer)
	return nil
}