Skip to content

Home > @esengine/ecs-framework-monorepo > Pool

Pool class

高性能通用对象池 支持任意类型的对象池化,包含详细的统计信息

Signature:

typescript
export declare class Pool<T extends IPoolable>

Constructors

Constructor

Modifiers

Description

(constructor)(createFn, maxSize, estimatedObjectSize)

构造函数

Methods

Method

Modifiers

Description

clear()

清空池

clearAllPools()

static

清空所有池

compact(targetSize)

压缩池(移除多余的对象)

compactAllPools()

static

压缩所有池

getAllPoolStats()

static

获取所有池的统计信息

getAllPoolTypes()

static

获取所有已注册的池类型

getAvailableCount()

获取池中可用对象数量

getGlobalStatsString()

static

获取全局池统计信息的格式化字符串

getPool(type, maxSize, estimatedObjectSize)

static

获取指定类型的对象池

getStats()

获取池统计信息

isEmpty()

检查池是否为空

isFull()

检查池是否已满

obtain()

从池中获取对象

prewarm(count)

预填充池

release(obj)

释放对象回池中

setMaxSize(maxSize)

设置最大池大小

基于 MIT 许可证发布