(pooledResource)
| 130 | } |
| 131 | |
| 132 | _destroy(pooledResource) { |
| 133 | // FIXME: do we need another state for "in destruction"? |
| 134 | pooledResource.invalidate(); |
| 135 | this._allObjects.delete(pooledResource); |
| 136 | // NOTE: this maybe very bad promise usage? |
| 137 | const destroyPromise = this._factory.destroy(pooledResource.obj); |
| 138 | const wrappedDestroyPromise = this._config.destroyTimeoutMillis |
| 139 | ? this._Promise.resolve(this._applyDestroyTimeout(destroyPromise)) |
| 140 | : this._Promise.resolve(destroyPromise); |
| 141 | |
| 142 | this._trackOperation( |
| 143 | wrappedDestroyPromise, |
| 144 | this._factoryDestroyOperations |
| 145 | ).catch(reason => { |
| 146 | this.emit(FACTORY_DESTROY_ERROR, reason); |
| 147 | }); |
| 148 | |
| 149 | // TODO: maybe ensuring minimum pool size should live outside here |
| 150 | this._ensureMinimum(); |
| 151 | } |
| 152 | |
| 153 | _applyDestroyTimeout(promise) { |
| 154 | const timeoutPromise = new this._Promise((resolve, reject) => { |
no test coverage detected