Permalink
Browse files

whoops using should be a property too >_<

  • Loading branch information...
1 parent 2a4ed65 commit 6e31fd3c54c0ce852499202f247f6d95415517f2 @substack committed Nov 24, 2010
Showing with 6 additions and 7 deletions.
  1. +5 −6 index.js
  2. +1 −1 package.json
View
@@ -8,6 +8,7 @@ function Resources () {
var self = this;
var resources = self.resources = {};
var queue = self.queue = [];
+ self.using = 0;
self.add = function (key, res) {
resources[key] = {
@@ -46,8 +47,6 @@ function Resources () {
return token;
};
- var using = 0;
-
self.release = function (token) {
var i = queue.map(function (q) { return q.token }).indexOf(token);
if (i >= 0) { // in the queue
@@ -68,7 +67,7 @@ function Resources () {
res.lease = null;
res.emit = null;
- using -= 1;
+ self.using -= 1;
var q = queue.shift();
if (q) {
@@ -78,7 +77,7 @@ function Resources () {
});
}
self.emit('waiting', queue.length);
- self.emit('using', using);
+ self.emit('using', self.using);
}
};
@@ -97,7 +96,7 @@ function Resources () {
}, ms);
emit('available', res.resource, res.key, res.lease);
- using += 1;
- self.emit('using', using);
+ self.using += 1;
+ self.emit('using', self.using);
}
}
View
@@ -1,6 +1,6 @@
{
"name" : "waitlist",
- "version" : "0.0.2",
+ "version" : "0.0.3",
"description" : "Manage consumers standing in queue for resources.",
"modules" : {
"index" : "./index.js",

0 comments on commit 6e31fd3

Please sign in to comment.