public TaskPoolNode Find(PiagetTask node) { TaskPoolNode current = this.First; while (current.task != node) // Loop thru all the pool { current = current.next; } return(current); }
public void Remove(PiagetTask task) { TaskPoolNode executing_task_pool_node = Find(task); if (task == task.next) // No other tasks in the same task pool node ? (which means that the task isn't the child of another task) { Remove(executing_task_pool_node); } else // Remove the task from the current task pool node, so that the task manager can switch to its parent task { PiagetTask child_task = executing_task_pool_node.task; PiagetTask parent_task = task.previous; PiagetTask bottom_task = child_task.next; parent_task.next = bottom_task; bottom_task.previous = parent_task; executing_task_pool_node.task = parent_task; // As the parent task is now activated, its wake-up time needs to be updated with regards to the current time parent_task.ResetWakeupTime(); } }
public TaskPoolNode(PiagetTask task) { this.task = task; }
public void Add(PiagetTask task) { TaskPoolNode task_pool_node = new TaskPoolNode(task); Add(task_pool_node); }
public TaskPool(PiagetTask persistant_task) : base(get_wakeup_time) { this.persistant_task = persistant_task; Add(new TaskPoolNode(persistant_task)); }