diff --git a/index.js b/index.js index c18e39c..257681b 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,3 @@ exports = module.exports = require('./lib/extracter'); -exports.version = '0.2.0'; \ No newline at end of file +exports.version = '0.2.1'; \ No newline at end of file diff --git a/lib/extracter.js b/lib/extracter.js index 9908471..f6c394f 100644 --- a/lib/extracter.js +++ b/lib/extracter.js @@ -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); @@ -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) { @@ -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 = []; @@ -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); + } + }); } } @@ -138,7 +143,6 @@ module.exports = function (opts) { var param = _freeWorker.get(); return _onGet(param.connectionId, param.num); } - } function _checkMaxJob(num) { diff --git a/package.json b/package.json index dce8313..b4a0aef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "url-extract", - "version": "0.2.0", + "version": "0.2.1", "description": "Snapshot & extract url library", "keywords": [ "snapshot",