const event = require('myevents');


let taskList = {},
    QUEUE_STATUS = true //全局任务状态 ， 0 可以进行下一个任务;

module.exports = {
    add: function (task) {
        if (taskList[task._id]) {
            return false;
        }
        taskList[task._id] = task;
        return true;
    },
    remove: function (_id) {
        taskList[_id] = null;
        delete taskList[_id];
    },
    clear: function name(params) {
        taskList = {};
    },
    find: function (_id) {
        return taskList[_id];
    },
    list: function () {
        return taskList;
    },
    stopAll: function () {
        QUEUE_STATUS = false;
    },
    startAll: function () {
        QUEUE_STATUS = true;
    },
    get queue_status() {
        return QUEUE_STATUS;
    },
    get taskNum() {
        return Object.keys(taskList).length;
    }
};
