aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
l---------gpool/LICENSE1
-rw-r--r--gpool/pool.go16
3 files changed, 22 insertions, 4 deletions
diff --git a/README.md b/README.md
index 0a49657..d20b20d 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,11 @@ This needs to be addressed in the future.
## Ported/forked packages
-| Name | Description | Origin | License |
-| - | - | - | - |
-| scfg | Configuration parsing library | emersion | MIT |
-| cmap | Generic concurrent maps | Go | BSD-3-Clause |
+| Name | Description | Origin | License |
+| - | - | - | - |
+| scfg | Configuration parsing library | emersion | MIT |
+| cmap | Generic concurrent maps | Go | BSD-3-Clause |
+| gpool | Generic wrapper for sync.Pool | Go | BSD-3-Clause |
## Custom packages
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)
+}