/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
function t(t){return t?.release&&"function"==typeof t.release}function i(t){return t?.acquire&&"function"==typeof t.acquire}class e{constructor(t,i,e,o=1,s=0){this._creator=t,this._acquireFunction=i,this._releaseFunction=e,this.allocationSize=o,this._pool=new Array(s),this._initialSize=s;for(let n=0;n<s;n++)this._pool[n]=this._creator();this.allocationSize=Math.max(o,1)}destroy(){this.prune(0)}acquire(...t){if(0===this._pool.length){const t=this.allocationSize;for(let i=0;i<t;i++)this._pool[i]=this._creator()}const e=this._pool.pop();return this._acquireFunction?this._acquireFunction(e,...t):i(e)&&e.acquire(...t),e}release(i){i&&(this._releaseFunction?this._releaseFunction(i):t(i)&&i.release(),this._pool.push(i))}prune(t=this._initialSize){if(!(t>=this._pool.length)){for(let i=t;i<this._pool.length;++i){const t=this._pool[i];this._dispose(t)}this._pool.length=t}}_dispose(t){t.dispose&&"function"==typeof t.dispose&&t.dispose()}}export{e as default};
