Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
Pool is a generic wrapper around sync.Pool that provides type-safe Get and Put methods. This eliminates the need for type assertions in the calling code and allows the compiler to optimize better since exact types are known at compile time.
Example usage:
type MyData struct { /* ... */ }
pool := utils.NewPool(func() *MyData { return &MyData{} })
data := pool.Get() // Returns *MyData, no type assertion needed
// ... use data ...
pool.Put(data)
func NewPool ¶
NewPool creates a new generic Pool with the given constructor function. The constructor is called when the pool is empty and needs to create a new value.
Click to show internal directories.
Click to hide internal directories.