* Forcibly destroys all available resources regardless of timeout. Intended to be * invoked as part of a drain. Does not prevent the creation of new * resources as a result of subsequent calls to acquire. * * Note that if factory.min > 0 and the pool isn't "draining", the pool will des
()
| 617 | * |
| 618 | */ |
| 619 | clear() { |
| 620 | const reflectedCreatePromises = Array.from( |
| 621 | this._factoryCreateOperations |
| 622 | ).map(reflector); |
| 623 | |
| 624 | // wait for outstanding factory.create to complete |
| 625 | return this._Promise.all(reflectedCreatePromises).then(() => { |
| 626 | // Destroy existing resources |
| 627 | // @ts-ignore |
| 628 | for (const resource of this._availableObjects) { |
| 629 | this._destroy(resource); |
| 630 | } |
| 631 | const reflectedDestroyPromises = Array.from( |
| 632 | this._factoryDestroyOperations |
| 633 | ).map(reflector); |
| 634 | return reflector(this._Promise.all(reflectedDestroyPromises)); |
| 635 | }); |
| 636 | } |
| 637 | |
| 638 | /** |
| 639 | * Waits until the pool is ready. |
no test coverage detected