diff --git a/creational/object_pool.go b/creational/object_pool.go index 2a73706..6ef65a5 100644 --- a/creational/object_pool.go +++ b/creational/object_pool.go @@ -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 +}