Create object_pool.go

This commit is contained in:
YikesHome 2019-10-31 02:04:43 +08:00 committed by GitHub
parent 7759f2ede9
commit 2584747936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
creational/object_pool.go Normal file
View File

@ -0,0 +1,13 @@
package pool
type Pool chan *Object
func New(total int) *Pool {
p := make(Pool, total)
for i := 0; i < total; i++ {
p <- new(Object)
}
return &p
}