码迷,mamicode.com
首页 > Web开发 > 详细

node.js任务调度器

时间:2016-05-27 20:16:22      阅读:600      评论:0      收藏:0      [点我收藏+]

标签:

//调度器
var list = Array();
var exc, cek;
var checkertime = 1000;
cek = checker(checkertime);
function checker(intervaltime) {
    interval = setInterval(function () {
        if (list.length > 0) {
            clearInterval(cek);
            exc = excutor(2);
            console.log(‘on excutor‘);
        } else {
            console.log(‘off excutor‘);
        }
    }, intervaltime);
    return interval;
}

function excutor(intervaltime) {
    var interval = setInterval(function () {
        if (list.length > 0) {
            console.log(list.pop());
        } else {
            clearInterval(exc);
            cek = checker(checkertime);
        }
    }, intervaltime);
    return interval;
}

list.push(‘1‘);
var ddd = setInterval(function () {
    list.push(‘2‘);
    list.push(‘2‘); list.push(‘2‘); list.push(‘2‘); list.push(‘2‘); list.push(‘2‘); list.push(‘2‘);
    clearInterval(ddd);
},10000);

node.js任务调度器

标签:

原文地址:http://www.cnblogs.com/jacle169/p/5535714.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!