UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

54 lines 1.28 kB
/** * Object Pool pattern implementation. * Reuse objects instead of relying on garbage collector. Useful in cases where creating or destroying an object is costly, and objects are relatively short-lived * @template T */ export class ObjectPoolFactory<T> { /** * @param {function():T} creator * @param {function(T)} destroyer * @param {function(T)} resetter */ constructor(creator: () => T, destroyer?: (arg0: T) => any, resetter?: (arg0: T) => any); /** * @private * @type {Array<T>} */ private pool; /** * @type {number} */ maxSize: number; /** * @private * @type {function(): T} */ private creator; /** * @private * @type {function(T)} */ private destroyer; /** * @private * @type {function(T)} */ private resetter; /** * * @returns {T} */ get(): T; /** * * @param {T} object * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead */ release(object: T): boolean; /** * @deprecated use `get` instead * @type {function(): T} */ create: () => T; } //# sourceMappingURL=ObjectPoolFactory.d.ts.map