blob: c074637aaf2e1db64db8c5417c07ce407ec7d30f [file] [log] [blame]
package sftp
type bufPool struct {
ch chan []byte
blen int
}
func newBufPool(depth, bufLen int) *bufPool {
return &bufPool{
ch: make(chan []byte, depth),
blen: bufLen,
}
}
func (p *bufPool) Get() []byte {
select {
case b := <-p.ch:
return b
default:
return make([]byte, p.blen)
}
}
func (p *bufPool) Put(b []byte) {
select {
case p.ch <- b:
default:
}
}