Update object_pool.go

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

View File

@ -11,3 +11,17 @@ func New(total int) *Pool {
return &p
}
p := New(2)
select {
case obj := <-p:
obj.Do( /*...*/ )
p <- obj
default:
// No more objects left — retry later or fail
return
}