Class zebkit.util.TasksSet | <zebkit.util> |
Task set is light-weight class to host number of callbacks methods that are called within a context of one JS interval method execution. The class manages special tasks queue to run it one by one as soon as a dedicated interval for the given task is elapsed
var tasks = new zebkit.util.TasksSet();
tasks.run(function(t) {
// task1 body
...
if (condition) {
t.shutdown();
}
}, 1000, 200);
tasks.run(function(t) {
// task2 body
...
if (condition) {
t.shutdown();
}
}, 2000, 300);
zebkit.util.TasksSet
([maxTasks]
)
Parameters:
-
[maxTasks]
<Integer>maximal possible number of active tasks in queue.
public | <zebkit.util.Task> | run (f, [si], [ri]) |
public | void | runOnce (f, [startIn]) |
protected
|
<Boolean> | shutdown (t) |
public | void | shutdownAll ( ) |
public
<zebkit.util.Task>
run (f, [si], [ri] )
Take a free task from pool and run it with the specified body and the given context. Parameters:
Returns:
<zebkit.util.Task>
an allocated task Example:
|
public
void
runOnce (f, [startIn] )
Take a free task from tasks pool and run it once in the specified period of time. Parameters:
|
protected
<Boolean>
shutdown (t )
Shutdown the given task Parameters:
Returns:
<Boolean>
true if the task has been stopped, false if the task has not been started to be stopped |
public
void
shutdownAll ( )
Shut down all active at the given moment tasks body and the given context. |