Skip to content

Commit

Permalink
fix pool never closing when evictor is enabled and pool.close not called
Browse files Browse the repository at this point in the history
clear up some documentation and comments
  • Loading branch information
James Butler committed Nov 26, 2016
1 parent a85ba82 commit 0cdefe6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/Pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,17 +469,21 @@ class Pool extends EventEmitter {

/**
* Disallow any new acquire calls and let the request backlog dissapate.
* Resolves once all resources are returned to pool and available...
* should probably be called "drain work"
* The Pool will no longer attempt to maintain a "min" number of resources
* and will only make new resources on demand.
* Resolves once all resource requests are fulfilled and all resources are returned to pool and available...
* Should probably be called "drain work"
* @returns {Promise}
*/
drain () {
// disable the ability to put more work on the queue.
this._draining = true
return this.__allResourceRequestsSettled()
.then(() => {
return this.__allResourcesReturned()
})
.then(() => {
this._descheduleEvictorRun()
})
}

__allResourceRequestsSettled () {
Expand Down Expand Up @@ -511,13 +515,10 @@ class Pool extends EventEmitter {
*
*/
clear () {
this._descheduleEvictorRun()
// wait for outstanding factory.create to complete
// FIXME: any new factory.create calls created after this will not
// handled by us
const reflectedCreatePromises = Array.from(this._factoryCreateOperations)
.map(reflector)

// wait for outstanding factory.create to complete
return this._Promise.all(reflectedCreatePromises)
.then(() => {
// Destroy existing resources
Expand Down

0 comments on commit 0cdefe6

Please sign in to comment.