aboutsummaryrefslogtreecommitdiff
path: root/gpool
diff options
context:
space:
mode:
Diffstat (limited to 'gpool')
l---------gpool/LICENSE1
-rw-r--r--gpool/pool.go16
2 files changed, 17 insertions, 0 deletions
diff --git a/gpool/LICENSE b/gpool/LICENSE
new file mode 120000
index 0000000..97a673a
--- /dev/null
+++ b/gpool/LICENSE
@@ -0,0 +1 @@
+../LICENSE.3BSD \ No newline at end of file
diff --git a/gpool/pool.go b/gpool/pool.go
new file mode 100644
index 0000000..9959b0d
--- /dev/null
+++ b/gpool/pool.go
@@ -0,0 +1,16 @@
+package gpool
+
+import "sync"
+
+type Pool[T any] struct {
+ p sync.Pool
+ New func() T
+}
+
+func (p *Pool[T]) Get() T {
+ return p.p.Get().(T)
+}
+
+func (p *Pool[T]) Put(x T) {
+ p.p.Put(x)
+}