mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-22 04:36:02 +03:00
creational/object-pool: fix typos
This commit is contained in:
parent
af1dfcd39f
commit
a523c5f6f3
@ -11,13 +11,13 @@ package pool
|
|||||||
type Pool chan *Object
|
type Pool chan *Object
|
||||||
|
|
||||||
func New(total int) *Pool {
|
func New(total int) *Pool {
|
||||||
p := make(chan *Object, total)
|
p := make(Pool, total)
|
||||||
|
|
||||||
for i := 0; i < total; i++ {
|
for i := 0; i < total; i++ {
|
||||||
p <- new(Object)
|
p <- new(Object)
|
||||||
}
|
}
|
||||||
|
|
||||||
return p
|
return &p
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ case obj := <-p:
|
|||||||
|
|
||||||
p <- obj
|
p <- obj
|
||||||
default:
|
default:
|
||||||
// No more objects left retry later or fail
|
// No more objects left — retry later or fail
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -45,4 +45,4 @@ default:
|
|||||||
expensive than the object maintenance.
|
expensive than the object maintenance.
|
||||||
- If there are spikes in demand as opposed to a steady demand, the maintenance
|
- If there are spikes in demand as opposed to a steady demand, the maintenance
|
||||||
overhead might overweigh the benefits of an object pool.
|
overhead might overweigh the benefits of an object pool.
|
||||||
- It has positive effects on performance due to object being initialized beforehand.
|
- It has positive effects on performance due to objects being initialized beforehand.
|
||||||
|
Loading…
Reference in New Issue
Block a user