Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool is a type-safe pool of items that does not allocate pointers to items. That is not entirely true, it does allocate sometimes, but not most of the time, just like the usual sync.Pool pools items most of the time, except when they're evicted. It does that by storing the allocated pointers in a secondary pool instead of letting them go, so they can be used later to store the items again.
Zero value of Pool[T] is valid, and it will return zero values of T if nothing is pooled.
func New ¶
New creates a new Pool[T] with the given function to create new items. A Pool must not be copied after first use.
Click to show internal directories.
Click to hide internal directories.