diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-08-08 00:19:33 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2019-08-08 00:19:33 +0200 |
commit | fde18e485ff7cbc7b2e33dade8e81136f06a5b60 (patch) | |
tree | 79a6dbd13e7e4a46e708a70104c548f403b477ae /vendor/github.com/oxtoacart/bpool/bufferpool.go | |
parent | 93e1de570f47b095905835735dbd67479aa0c2de (diff) |
[pkg] remove vendor
Diffstat (limited to 'vendor/github.com/oxtoacart/bpool/bufferpool.go')
-rw-r--r-- | vendor/github.com/oxtoacart/bpool/bufferpool.go | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/vendor/github.com/oxtoacart/bpool/bufferpool.go b/vendor/github.com/oxtoacart/bpool/bufferpool.go deleted file mode 100644 index 8c8ac64..0000000 --- a/vendor/github.com/oxtoacart/bpool/bufferpool.go +++ /dev/null @@ -1,40 +0,0 @@ -package bpool - -import ( - "bytes" -) - -// BufferPool implements a pool of bytes.Buffers in the form of a bounded -// channel. -type BufferPool struct { - c chan *bytes.Buffer -} - -// NewBufferPool creates a new BufferPool bounded to the given size. -func NewBufferPool(size int) (bp *BufferPool) { - return &BufferPool{ - c: make(chan *bytes.Buffer, size), - } -} - -// Get gets a Buffer from the BufferPool, or creates a new one if none are -// available in the pool. -func (bp *BufferPool) Get() (b *bytes.Buffer) { - select { - case b = <-bp.c: - // reuse existing buffer - default: - // create new buffer - b = bytes.NewBuffer([]byte{}) - } - return -} - -// Put returns the given Buffer to the BufferPool. -func (bp *BufferPool) Put(b *bytes.Buffer) { - b.Reset() - select { - case bp.c <- b: - default: // Discard the buffer if the pool is full. - } -} |