mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 21:26:04 +00:00
Update task.js
This commit is contained in:
parent
317d0d60b3
commit
fda2b3fdec
17
lib/task.js
17
lib/task.js
|
@ -16,14 +16,14 @@
|
||||||
* // taskQueue.run();
|
* // taskQueue.run();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Task = function(f, params, when)
|
var Task = function(f, params, when) {
|
||||||
this.f = f;
|
this.f = f;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.nextTask = null;
|
this.nextTask = null;
|
||||||
this.when = (typeof(when) === "number" ? when : 0);
|
this.when = (typeof(when) === "number" ? when : 0);
|
||||||
this.setNextTask = function(task) {
|
this.setNextTask = function(task) {
|
||||||
this.nextTask = task;
|
this.nextTask = task;
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var TaskQueue = function() {
|
var TaskQueue = function() {
|
||||||
|
@ -42,11 +42,12 @@ var TaskQueue = function() {
|
||||||
};
|
};
|
||||||
this.get = function() {
|
this.get = function() {
|
||||||
var task = null;
|
var task = null;
|
||||||
var now = new Date().getTime();
|
//var now = new Date().getTime();
|
||||||
var delta = now;
|
//var delta = now;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.queue.length > 0) {
|
if (this.queue.length > 0) {
|
||||||
|
/*
|
||||||
var k = 0;
|
var k = 0;
|
||||||
for (var i = 0; i < this.queue.length; i++) {
|
for (var i = 0; i < this.queue.length; i++) {
|
||||||
var _delta = now - this.queue[i].when;
|
var _delta = now - this.queue[i].when;
|
||||||
|
@ -57,6 +58,10 @@ var TaskQueue = function() {
|
||||||
}
|
}
|
||||||
task = this.queue[k];
|
task = this.queue[k];
|
||||||
this.queue = this.queue.splice(k, 1);
|
this.queue = this.queue.splice(k, 1);
|
||||||
|
*/
|
||||||
|
task = this.queue[0];
|
||||||
|
this.queue = this.queue.slice(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error("TaskQueue.get: " + e.message);
|
console.error("TaskQueue.get: " + e.message);
|
||||||
|
@ -194,3 +199,7 @@ exports.Promise = function() {
|
||||||
// ... todo ...
|
// ... todo ...
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
exports.VERSIONINFO = "Task Module (task.js) version 0.1";
|
||||||
|
exports.global = global;
|
||||||
|
exports.require = require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user