//! ƒ^ƒXƒN
var Task = Class.create();
Task.prototype = {
	initialize : function() {
		this.work = new Array();
		this.wait = new Array();
		this.temp = new Array();
	},

	add : function(t) {
		this.wait.push(t);
	},

	pop : function(t) {
		var e = this.wait.pop();
		if (e) this.work.push(e);
		return e;
	},

	update : function() {
		var t;
		while(t = this.work.pop()) {
			t.update();
			if (t.kill) {
				t.kill = false;
				this.wait.push(t);
			}
			else this.temp.push(t);
		}
		while(t = this.temp.pop()) this.work.push(t);
	},

	render : function() {
		for(var i = 0; i < this.work.length; i++) this.work[i].render();
	}
};
