mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-29 00:25:20 +03:00
Create object_pool.go
This commit is contained in:
parent
7759f2ede9
commit
2584747936
13
creational/object_pool.go
Normal file
13
creational/object_pool.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user