使用Golang下chan实现一个缓冲池(Pool)
// BytesPool is a pool of byte slice that can ben used
type BytesPool struct {
pool chan []byte
}
func NewBytesPool(max int) *BytesPool {
return &BytesPool{
pool: make(chan []byte, max),
}
}
/
原创
2017-07-14 18:14:34 ·
5045 阅读 ·
0 评论