Skip to content

Commit

Permalink
Merge pull request #2 from miniflycn/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
skyhacker2 committed Dec 8, 2013
2 parents 759a974 + c29b811 commit d75e1bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports = module.exports = require('./lib/extracter');

exports.version = '0.2.0';
exports.version = '0.2.1';
20 changes: 12 additions & 8 deletions lib/extracter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = function (opts) {
, _callback = _noop
, _freeWorker = new Map()
, _connectionId2jobList = new Map()
, _job2connectionId = {};
, _job2connectionId = {}
, _unfinish = config.unfinish || _noop;

function _pushFreeWorker(connectionId, num) {
var free = _freeWorker.get(connectionId);
Expand Down Expand Up @@ -73,7 +74,6 @@ module.exports = function (opts) {
}

function _onGet(connectionId, num) {
// console.log('connectionId: ' + connectionId + ' get num: ' + num);
var jobList = jobPool.shift(num)
, len = jobList.length;
if (len > 0) {
Expand Down Expand Up @@ -105,7 +105,6 @@ module.exports = function (opts) {
}

function _onDied(connectionId) {
// console.log ('connectionId: ' + connectionId + ' Died.');
var jobList = _connectionId2jobList.get(connectionId);
_connectionId2jobList.remove(connectionId);
var unfinish = [];
Expand All @@ -116,10 +115,16 @@ module.exports = function (opts) {
unfinish.push(jobs[0]);
}
}
if (unfinish.length > 0)
_success(unfinish, true);

console.log('unfinish job: ' + unfinish.length);
unfinish.length > 0 &&
_unfinish({
_: unfinish,
push: function () {
return jobPool.push(unfinish);
},
unshift: function () {
return jobPool.unshift(unfinish);
}
});
}
}

Expand All @@ -138,7 +143,6 @@ module.exports = function (opts) {
var param = _freeWorker.get();
return _onGet(param.connectionId, param.num);
}

}

function _checkMaxJob(num) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "url-extract",
"version": "0.2.0",
"version": "0.2.1",
"description": "Snapshot & extract url library",
"keywords": [
"snapshot",
Expand Down

0 comments on commit d75e1bd

Please sign in to comment.