Skip to content

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

ComponentPool class

组件对象池,用于复用组件实例以减少内存分配

Signature:

typescript
export declare class ComponentPool<T extends Component>

Constructors

Constructor

Modifiers

Description

(constructor)(createFn, resetFn, maxSize)

Constructs a new instance of the ComponentPool class

Methods

Method

Modifiers

Description

acquire()

获取一个组件实例

clear()

清空对象池

getAvailableCount()

获取池中可用对象数量

getMaxSize()

获取池的最大容量

prewarm(count)

预填充对象池

release(component)

释放一个组件实例回池中

基于 MIT 许可证发布