Methods Summary |
---|
protected boolean | addTask(PeriodicallyServicable taskObj, int startingTime, long currentTime)Add a new servicable task into the task list (ordered in increasing order).
TaskData task = new TaskData();
task.obj = taskObj;
// decrement frequency time as it will be added on insertTask( ) anyway
task.abs_execute_time = currentTime + startingTime - taskObj.getFrequency();
return insertTask(task);
|
protected TaskData | getFirstTask()Remove first task from the ordered list, and return it.
DListNode node = first;
node = node.next;
if(null!=node.next) // not the end
{
node.delink();
--size;
return (TaskData) node.object;
}
return null;
|
protected boolean | insertTask(TaskData task)Insert task back into the task list (ordered in increasing order).
task.abs_execute_time += ((PeriodicallyServicable)task.obj).getFrequency();
DListNode addingNode = new DListNode(task);
DListNode node = first;
++size;
for(int i=0; i<size-1; i++)
{
node = node.next;
long nodeTime = ((TaskData)node.object).abs_execute_time;
if(nodeTime > task.abs_execute_time)
{
node.insertBefore(addingNode);
return true;
}
}
node.insertAfter(addingNode);
return true;
|
protected boolean | removeTask(PeriodicallyServicable obj)Removes the Servicable object from the task list permanently.
DListNode node = first;
for(int i=0; i<size; i++)
{
node = node.next;
PeriodicallyServicable nodeObj = ((TaskData)node.object).obj;
if(nodeObj.equals(obj))
{
node.delink();
--size;
return true;
}
}
return false;
|
protected int | size()Return the size of the task list.
return size;
|
public java.lang.String | toString()Prints information about the list and its contents.
StringBuffer sb = new StringBuffer(100);
sb.append(" [TimedTaskList: ");
sb.append( size + " elements: ");
DListNode node = first;
while(null!=node.next && null!=node.next.object)
{
node = node.next;
sb.append((int) ( ((TaskData)node.object).abs_execute_time / 1000) );
sb.append(",");
}
sb.append("] ");
return sb.toString();
|