Closed kokujin closed 10 years ago
Hi, kokujin,
looks like an infinite recursion.
Please check the docs on 'autostop' option. If you choose 'autostop' to be true (default), please add listener to 'stop' event that adds more tasks and executes the queue again. Alternatively, set autostop option to false to make the queue wait for tasks forever.
Example 1. (autostop)
var TasksQueue = require('tasks-queue');
var q = new TasksQueue();
q.setMinTime(1000);
q.on('stop', taskRunner);
q.on('task', ontask);
function taskRunner (jinn) {
var q = jinn.getQueue();
console.log('All tests are done');
q.pushTask('task',{n:40});
q.pushTask('task',{n:50});
q.execute();
}
function ontask (jinn, data) {
console.log('n = %d', data.n);
jinn.done();
}
q.execute();
Example2 (noautostop)
var TasksQueue = require('tasks-queue');
var q = new TasksQueue({autostop:false});
q.setMinTime(100);
q.on('task', ontask);
q.execute();
setInterval(taskRunner, 1000)
function ontask (jinn, data) {
console.log('n = %d', data.n);
jinn.done();
}
function taskRunner () {
console.log('All tests are done');
q.pushTask('task',{n:40});
q.pushTask('task',{n:50});
}
Closing since there's no reply.
I am trying to make sure that a queue runs continuously. The snippet below fails, can someone tell me what I am doing wrong? Thanks
function taskRunner(){ if(q.length() == 0){ console.log('All tests done!'.green); q.pushTask('task',{n:40}); q.pushTask('task',{n:50}); taskRunner();
}
q.execute();
}
taskRunner();