Lindenii Project Forge
Login

go-lindenii-common

Common library for the Lindenii Project
Commit info
ID
561db30e03d5cf22709c8dbf091c5ea61717695e
Author
Runxi Yu <me@runxiyu.org>
Author date
Fri, 21 Mar 2025 21:12:36 +0800
Committer
Runxi Yu <me@runxiyu.org>
Committer date
Fri, 21 Mar 2025 21:14:13 +0800
Actions
gpool: Generic wrapper for sync.Pool
# Common Go libraries for Lindenii projects

## Warning

Currently this only works on Linux because we use Linux-specific system calls.
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

All custom packages are licensed under CC0-1.0.

| Name   | Description       |
| -      | -                 |
| misc   | Misc functions    |
| clog   | Logging utilities |
| ansiec | ANSI escape codes |
../LICENSE.3BSD
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)
}