Source File
pool.go
Belonging Package
github.com/gotd/td/bin
package bin
import
// Pool is a bin.Buffer pool.
type Pool struct {
pool sync.Pool
}
// NewPool creates new Pool.
// Length is initial buffer length.
func ( int) *Pool {
return &Pool{
pool: sync.Pool{
New: func() interface{} {
var []byte
if > 0 {
= make([]byte, 0, )
}
return &Buffer{Buf: }
},
},
}
}
// Put returns buffer to pool.
func ( *Pool) ( *Buffer) {
.pool.Put()
}
// Get takes buffer from pool.
func ( *Pool) () *Buffer {
:= .pool.Get().(*Buffer)
.Reset()
return
}
// GetSize takes buffer with given size from pool.
func ( *Pool) ( int) *Buffer {
:= .Get()
.ResetN()
return
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |