Mercurial > hg > Game > Cerium
view TaskManager/Fifo/FifoTaskInfo.cc @ 6:39ce245235d4
*** empty log message ***
author | gongo |
---|---|
date | Wed, 06 Feb 2008 11:41:08 +0900 |
parents | 75f184d16fa5 |
children | 7aa4c006e4be |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "FifoTaskInfo.h" void FifoTaskInfo::init(void) { taskListPool = NULL; freeTaskList = NULL; taskQueuePool = NULL; freeTaskQueue = NULL; activeTaskQueue = NULL; waitTaskQueue = NULL; taskPool = NULL; freeTask = NULL; init_taskList(2); init_taskQueue(TASK_MAX_SIZE*4); init_task(TASK_MAX_SIZE); machineTaskList = get_free_taskList(); } int FifoTaskInfo::extend_pool_taskList(int num) { TaskListPtr q = NULL; q = (TaskListPtr)malloc(sizeof(TaskList)*(num+1)); if (q == NULL) { return -1; } q->next = taskListPool; taskListPool = q; /* Connect all free pack_list in the pool */ for (q = taskListPool + 1; --num > 0; q++) { q->next = q + 1; } q->next = freeTaskList; freeTaskList = taskListPool + 1; return 0; } TaskListPtr FifoTaskInfo::get_available_taskList(void) { TaskListPtr list, q; list = machineTaskList; while (list->next) list = list->next; if (list->length < TASK_MAX_SIZE) { return list; } else { q = get_free_taskList(); machineTaskList = append_taskList(machineTaskList, q); return q; } } void FifoTaskInfo::clear_taskList(void) { TaskListPtr p, p1; machineTaskList->length = 0; p = machineTaskList->next; while (p) { p1 = p; p = p->next; free_taskList(p1); } }