Update task.js

This commit is contained in:
Namhyeon Go 2021-06-25 03:43:54 +09:00 committed by GitHub
parent 317d0d60b3
commit fda2b3fdec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,14 +16,14 @@
* // taskQueue.run();
*/
var Task = function(f, params, when)
var Task = function(f, params, when) {
this.f = f;
this.params = params;
this.nextTask = null;
this.when = (typeof(when) === "number" ? when : 0);
this.setNextTask = function(task) {
this.nextTask = task;
}
};
};
var TaskQueue = function() {
@ -42,11 +42,12 @@ var TaskQueue = function() {
};
this.get = function() {
var task = null;
var now = new Date().getTime();
var delta = now;
//var now = new Date().getTime();
//var delta = now;
try {
if (this.queue.length > 0) {
/*
var k = 0;
for (var i = 0; i < this.queue.length; i++) {
var _delta = now - this.queue[i].when;
@ -57,6 +58,10 @@ var TaskQueue = function() {
}
task = this.queue[k];
this.queue = this.queue.splice(k, 1);
*/
task = this.queue[0];
this.queue = this.queue.slice(1);
}
} catch(e) {
console.error("TaskQueue.get: " + e.message);
@ -194,3 +199,7 @@ exports.Promise = function() {
// ... todo ...
};
*/
exports.VERSIONINFO = "Task Module (task.js) version 0.1";
exports.global = global;
exports.require = require;