go-pattern-examples/creation/04_object_pool/object_pool_test.go

21 lines
237 B
Go
Raw Normal View History

2020-04-24 13:09:58 +03:00
package objectpool
import (
"testing"
)
func TestObjectPool(t *testing.T) {
p := newPool(2)
select {
case obj := <-p:
obj.surgery( /*...*/ )
p <- obj
default:
// No more objects left — retry later or fail
return
}
}