* Push back an object instance into the object pool * Object pooling for the object class must be enabled, * and object must have been instantiated using pull, * otherwise this function won't work * @throws will throw an error if the object cannot be recycled * @param {object}
(obj, throwOnError = true)
| 170 | * @returns {boolean} true if the object was successfully recycled in the object pool |
| 171 | */ |
| 172 | push(obj, throwOnError = true) { |
| 173 | if (!this.poolable(obj)) { |
| 174 | if (throwOnError === true) { |
| 175 | throw new Error("me.pool: object " + obj + " cannot be recycled"); |
| 176 | } else { |
| 177 | return false; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | // store back the object instance for later recycling |
| 182 | this.objectClass[obj.className].pool.push(obj); |
| 183 | this.instance_counter++; |
| 184 | |
| 185 | return true; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Check if an object with the provided name is registered |