Executor also works without callbakc

pull/2/head
Louis Chatriot 12 years ago
parent 0a2b642dfc
commit c88026cf86
  1. 48
      lib/executor.js

@ -11,12 +11,7 @@ executor = async.queue(function (task, cb) {
, lastArg = task.arguments[task.arguments.length - 1]
;
//console.log("==================");
//console.log(task);
//console.log('---');
//console.log(lastArg);
//console.log("==================");
// Always tell the queue task is complete. Execute callback if any was given.
if (typeof lastArg === 'function') {
callback = function () {
lastArg(arguments);
@ -33,7 +28,7 @@ executor = async.queue(function (task, cb) {
}
task.fn.apply(task.this, task.arguments);
}, 2);
}, 1);
function test1 (msg, cb) {
@ -61,7 +56,7 @@ function test2 (msg, cb) {
function bloup () { console.log("FINISHED"); }
executor.push({ this: null, fn: test1, arguments: [ 'world', bloup ] });
executor.push({ this: null, fn: test1, arguments: [ 'world' ] });
executor.push({ this: null, fn: test2, arguments: [ 'world', bloup ] });
@ -123,42 +118,7 @@ q.unshift({name: 'bar'}, function (err) {
});
*/
/*
function Executor () {
}
Executor.prototype.enqueueAction = function (fn, thisArg) {
var callback
, self = this
, lastArg = arguments[arguments.length - 1];
console.log(arguments);
console.log(arguments.length);
// When finishing action, we need to launch the next one. We may also need to execute the callback for that action
if (lastArg === 'function') {
callback = function () {
lastArg(arguments);
self.launchNextAction();
};
} else {
callback = function () {
self.launchNextAction();
};
}
};
Executor.prototype.launchNextAction = function () {
console.log("LAUNCHED NEXT ACTION");
};
var e = new Executor();
e.enqueueAction(console.log, null, "a", 42);
*/
// Interface
//module.exports = Executor;
module.exports = executor;

Loading…
Cancel
Save