1 /** 2 * @class scheduler 3 * @extends component 4 * @description 5 * A component that allows for automatic running 6 * of logic at certain intervals. 7 * 8 * 9 */ 10 function scheduler() { 11 12 /** 13 * Begins a new task. A task will run 14 * once per every announced millisecond interval. 15 * The resolution is only as good as the number of times the 16 * host's step() is called. In an Engine context, this is usually 17 * locked to the sandboxe's max FPS. 18 * @param {String} name Name of the task. 19 * @param {Number} interval Interval in milliseconds. 20 * @param {Function} function Function to run at the given interval 21 */ 22 this.startTask = function(){}; 23 24 /** 25 * Halts the task with the given name. 26 * 27 * If there is no task with the given name, no action is taken. 28 * @param {String} name Name of the interval to end. 29 */ 30 this.endTask = function(){}; 31 32 /** 33 * Returns the millisecond rate of the given task name. 34 * @param {String} name 35 * @returns {Number} 36 */ 37 this.getTaskInterval = function(){}; 38 39 /** 40 * Resumes the scheduler from the pause state. 41 */ 42 this.resume = function(){}; 43 44 /** 45 * Pauses the timer from the pause state. 46 */ 47 this.pause = function(){}; 48 49 50 51 /** 52 * Returns all registered tasks by name. 53 * @type {Array} names 54 */ 55 this.tasks = 0.0; 56 57 58 59 60 61 return this; 62 }