Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultShardFactor = 2 // e.g., 2 shards per core
DefaultShardFactor determines how many shards per CPU core. Can be tuned based on specific workload benchmarks.
Variables ¶
View Source
var ErrPoolClosed = errors.New("boundedpool: pool is closed")
ErrPoolClosed is returned when an operation is attempted on a closed pool.
Functions ¶
This section is empty.
Types ¶
type Pooler ¶
type Pooler[T any] interface { // Get retrieves an item from the pool or creates a new one if the pool is empty. Get() (T, error) // Put adds an item back to the pool into one of the shards. Put(item T) error // Close closes the pool, preventing further Gets or Puts. Close() bool // Len returns the approximate total number of items currently in the pool. Len() int // Cap returns the total capacity of the pool across all shards. Cap() int // NumShards returns the number of internal shards being used. NumShards() int }
Pooler defines the interface for the bounded pool. This allows users to depend on the interface rather than the concrete implementation.
Click to show internal directories.
Click to hide internal directories.