/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import has from"../../../core/has.js";import t from"../../../core/PooledArray.js";class s{constructor(t,s){this._factoryCallback=t,this._lengthCallback=s,this._pool=new Map}acquire(t){if(!s.test.disabled){const s=this._pool.get(t);if(s&&0!==s.length)return s.pop()}try{return this._factoryCallback(t)}catch(e){throw e}}release(e){if(s.test.disabled)return;const o=this._lengthCallback(e);let r=this._pool.get(o);r||(r=new t({shrink:!0}),this._pool.set(o,r)),r.push(e)}clear(){this._pool.clear()}get test(){}static{this.test={disabled:!!has("esri-tests-disable-memory-pools")}}}export{s as BufferPool};
