Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds refreshIdle flag, defaulting to true

  • Loading branch information...
commit 94db33641d8a6c86f22ab8cad4abfc64f66b347a 1 parent 196e558
@wshaver wshaver authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/generic-pool.js
View
7 lib/generic-pool.js
@@ -88,7 +88,8 @@ var PriorityQueue = function(size) {
* that will be used instead. The function expects the arguments msg, loglevel
* @param {Number} factory.priorityRange
* The range from 1 to be treated as a valid priority
- *
+ * @param {RefreshIdle} factory.refreshIdle
+ * Should idle resources be destroyed and recreated every idleTimeoutMillis? Default: true.
* @returns {Object} An Object pool that works with the supplied `factory`.
*/
exports.Pool = function (factory) {
@@ -96,7 +97,7 @@ exports.Pool = function (factory) {
idleTimeoutMillis = factory.idleTimeoutMillis || 30000,
reapInterval = factory.reapIntervalMillis || 1000,
-
+ refreshIdle = ('refreshIdle' in factory) ? factory.refreshIdle : true,
availableObjects = [],
waitingClients = new PriorityQueue(factory.priorityRange || 1),
count = 0,
@@ -158,7 +159,7 @@ exports.Pool = function (factory) {
// Go through the available (idle) items,
// check if they have timed out
- for (i = 0, al = availableObjects.length; i < al && (count - factory.min) > toRemove.length ; i += 1) {
+ for (i = 0, al = availableObjects.length; i < al && (refreshIdle || (count - factory.min)) > toRemove.length ; i += 1) {
timeout = availableObjects[i].timeout;
if (now >= timeout) {
// Client timed out, so destroy it.
Please sign in to comment.
Something went wrong with that request. Please try again.