From 2584747936ba916c42132f1f9d74e3f669a2c07f Mon Sep 17 00:00:00 2001 From: YikesHome <31678324+yikeshome@users.noreply.github.com> Date: Thu, 31 Oct 2019 02:04:43 +0800 Subject: [PATCH] Create object_pool.go --- creational/object_pool.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 creational/object_pool.go diff --git a/creational/object_pool.go b/creational/object_pool.go new file mode 100644 index 0000000..2a73706 --- /dev/null +++ b/creational/object_pool.go @@ -0,0 +1,13 @@ +package pool + +type Pool chan *Object + +func New(total int) *Pool { + p := make(Pool, total) + + for i := 0; i < total; i++ { + p <- new(Object) + } + + return &p +}