Comparing version 0.1.0 to 0.1.1
0.1.1 / 2013-12-31 | ||
================== | ||
* fix item timeout | ||
0.1.0 / 2013-12-31 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -155,13 +155,5 @@ | ||
debug('timeout in %d', ms); | ||
tid = setTimeout(function(){ | ||
clearTimeout(tid); | ||
debug('timeout'); | ||
fn(); | ||
}, ms); | ||
if (this.items.length) { | ||
obj = this.items.pop(); | ||
return setImmediate(function(){ | ||
clearTimeout(tid); | ||
fn(null, obj); | ||
@@ -173,5 +165,13 @@ debug('acquired, total items: %d', self.items.length); | ||
debug('timeout in %d', ms); | ||
tid = setTimeout(function(){ | ||
clearTimeout(tid); | ||
debug('timeout'); | ||
fn(); | ||
}, ms); | ||
if (this._constructor) { | ||
return this.generate(function(err, item){ | ||
if (err) return fn(err); | ||
if (item) clearTimeout(tid); | ||
if (item) return self.acquire(fn); | ||
@@ -275,3 +275,4 @@ self.once('return', function(){ | ||
if (fn) fn(obj); | ||
--this.added; | ||
return this; | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"repo": "yields/apool", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"dependencies": { | ||
@@ -8,0 +8,0 @@ "debug": "~0.7.4", |
@@ -127,2 +127,20 @@ | ||
describe('destruct()', function(){ | ||
it('should call destructor', function(){ | ||
var p = pool(); | ||
var obj = {}; | ||
p.destructor(function(obj){ obj.called = true; }); | ||
p.destruct(obj); | ||
obj.called.should.be.true; | ||
}) | ||
it('should decrement added', function(){ | ||
var p = pool(); | ||
p.destructor(function(){}); | ||
p.added.should.eql(0); | ||
p.destruct({}); | ||
p.added.should.eql(-1); | ||
}) | ||
}) | ||
describe('return()', function(){ | ||
@@ -129,0 +147,0 @@ it('should return an item to items', function(){ |
15396
490