Skip to content

Commit f515db9

Browse files
authored
Update object_pool.go
1 parent 2584747 commit f515db9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

creational/object_pool.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,17 @@ func New(total int) *Pool {
1111

1212
return &p
1313
}
14+
15+
16+
17+
p := New(2)
18+
19+
select {
20+
case obj := <-p:
21+
obj.Do( /*...*/ )
22+
23+
p <- obj
24+
default:
25+
// No more objects left — retry later or fail
26+
return
27+
}

0 commit comments

Comments
 (0)