Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

whoops using should be a property too >_<

  • Loading branch information...
commit 6e31fd3c54c0ce852499202f247f6d95415517f2 1 parent 2a4ed65
James Halliday authored

Showing 2 changed files with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. +5 6 index.js
  2. +1 1  package.json
11 index.js
@@ -8,6 +8,7 @@ function Resources () {
8 8 var self = this;
9 9 var resources = self.resources = {};
10 10 var queue = self.queue = [];
  11 + self.using = 0;
11 12
12 13 self.add = function (key, res) {
13 14 resources[key] = {
@@ -46,8 +47,6 @@ function Resources () {
46 47 return token;
47 48 };
48 49
49   - var using = 0;
50   -
51 50 self.release = function (token) {
52 51 var i = queue.map(function (q) { return q.token }).indexOf(token);
53 52 if (i >= 0) { // in the queue
@@ -68,7 +67,7 @@ function Resources () {
68 67 res.lease = null;
69 68 res.emit = null;
70 69
71   - using -= 1;
  70 + self.using -= 1;
72 71
73 72 var q = queue.shift();
74 73 if (q) {
@@ -78,7 +77,7 @@ function Resources () {
78 77 });
79 78 }
80 79 self.emit('waiting', queue.length);
81   - self.emit('using', using);
  80 + self.emit('using', self.using);
82 81 }
83 82 };
84 83
@@ -97,7 +96,7 @@ function Resources () {
97 96 }, ms);
98 97
99 98 emit('available', res.resource, res.key, res.lease);
100   - using += 1;
101   - self.emit('using', using);
  99 + self.using += 1;
  100 + self.emit('using', self.using);
102 101 }
103 102 }
2  package.json
... ... @@ -1,6 +1,6 @@
1 1 {
2 2 "name" : "waitlist",
3   - "version" : "0.0.2",
  3 + "version" : "0.0.3",
4 4 "description" : "Manage consumers standing in queue for resources.",
5 5 "modules" : {
6 6 "index" : "./index.js",

0 comments on commit 6e31fd3

Please sign in to comment.
Something went wrong with that request. Please try again.