Mercurial > hg > Game > Cerium
changeset 475:4e0308d2ba73 draft
BufferManager removed.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 04 Oct 2009 11:29:50 +0900 |
parents | c5f283bd88af |
children | 5fc79ff9c257 |
files | TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/Fifo/FifoTaskManagerImpl.h TaskManager/Test/test_render/viewer.cc TaskManager/kernel/ppe/BufferManager.cc TaskManager/kernel/ppe/BufferManager.h TaskManager/kernel/ppe/TaskListInfo.cc TaskManager/kernel/ppe/TaskListInfo.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/ppe/TaskQueueInfo.h |
diffstat | 10 files changed, 78 insertions(+), 171 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Sun Oct 04 11:29:50 2009 +0900 @@ -6,11 +6,15 @@ #include "types.h" #include "error.h" -FifoTaskManagerImpl::~FifoTaskManagerImpl(void) +FifoTaskManagerImpl::~FifoTaskManagerImpl() { delete mailManager; delete scheduler; - delete bufferManager; + + delete taskListImpl ; + delete taskQueueImpl ; + delete htaskImpl ; + } /** @@ -19,7 +23,7 @@ * BufferManager は Task、TaskList などのメモリ管理(大層なことしてないが */ void -FifoTaskManagerImpl::init(void) +FifoTaskManagerImpl::init() { mailManager = new MailManager(); mailManager->init(20); @@ -29,20 +33,27 @@ scheduler->set_mailManager(mailManager); scheduler->id = 0; - bufferManager = new BufferManager; - bufferManager->init(); + taskListImpl = new TaskListInfo; + taskQueueImpl = new TaskQueueInfo; + htaskImpl = new HTaskInfo; + + machineNum = machineNum*2; // What!? - mainTaskList = bufferManager->create_taskList(); + taskQueueImpl->init(TASK_MAX_SIZE*4); + htaskImpl->init(TASK_MAX_SIZE*2); + + mainTaskList = taskListImpl->create(); + } /** * これは CellTaskManagerImpl から呼ばれる。 - * BufferManager は共用で使うので引数に。 + * TaskList等 は共用で使うので引数に。 * CellTaskManagerImpl と FifoTaskManagerImpl が同時に * 上のデータにアクセスする事は(今は)ないのでこれでおk */ void -FifoTaskManagerImpl::init(MainScheduler *_sched, BufferManager *buff) +FifoTaskManagerImpl::init(MainScheduler *_sched, TaskManagerImpl *tm) { mailManager = new MailManager(); mailManager->init(20); @@ -52,9 +63,12 @@ scheduler->init(); scheduler->set_mailManager(mailManager); - bufferManager = buff; + taskListImpl = tm-> taskListImpl ; + taskQueueImpl = tm-> taskQueueImpl ; + htaskImpl = tm-> htaskImpl ; - mainTaskList = bufferManager->create_taskList(); + mainTaskList = taskListImpl->create(); + } /** @@ -66,7 +80,7 @@ * 実行タスクリストに入れる */ TaskListPtr -FifoTaskManagerImpl::get_runTaskList(void) +FifoTaskManagerImpl::get_runTaskList() { TaskListPtr list, list_top; TaskQueuePtr queue; @@ -83,7 +97,7 @@ list_top = mainTaskList; // list_top->clear() とかの方がいいかもしれん。 - list_top = bufferManager->clear_taskList(list_top); + list_top = taskListImpl->clear_taskList(list_top); list = list_top; while (queue) { @@ -93,22 +107,15 @@ task = &list->tasks[list->length++]; -#if 0 - task->command = htask->command; - task->inData = htask->inData; - task->outData = htask->outData; - task->self = (unsigned int)htask; -#else memcpy(task, htask, sizeof(Task)); -#endif if (list->length >= TASK_MAX_SIZE) { - TaskListPtr newList = bufferManager->create_taskList(); + TaskListPtr newList = taskListImpl->create(); list_top = TaskListInfo::append(list_top, newList); list = newList; } - bufferManager->free_taskQueue(d); + taskQueueImpl->free(d); } activeTaskQueue = NULL; @@ -119,7 +126,7 @@ void -FifoTaskManagerImpl::run(void) +FifoTaskManagerImpl::run() { TaskListPtr list; MailQueuePtr mail; @@ -231,9 +238,9 @@ } /** - * こういう使い方を + * # # # # # # # # * Abstract Factory Pattern - * というらしい。 + * # # # # # # # */ #ifdef __CERIUM_FIFO__ TaskManagerImpl* @@ -242,3 +249,4 @@ return new FifoTaskManagerImpl(); } #endif // __CERIUM_FIFO__ +
--- a/TaskManager/Fifo/FifoTaskManagerImpl.h Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.h Sun Oct 04 11:29:50 2009 +0900 @@ -21,7 +21,7 @@ /* functions */ // call by system void init(void); - void init(MainScheduler*, BufferManager*); + void init(MainScheduler*, TaskManagerImpl*); void run(void); void mail_check(MailQueuePtr mail_list); void mail_check(MailQueuePtr mail_list, TaskQueuePtr *waitQueue);
--- a/TaskManager/Test/test_render/viewer.cc Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cc Sun Oct 04 11:29:50 2009 +0900 @@ -13,7 +13,7 @@ static void post2runLoop(void *viewer); static void post2runDraw(void *viewer); -static void post2speRunLoop(void *viewer); +// static void post2speRunLoop(void *viewer); //static void post2runMove(void *viewer); //static void post2exchange_sgroot(void *viewer); static void post2speRunLoop(void *viewer);
--- a/TaskManager/kernel/ppe/BufferManager.cc Sat Oct 03 10:50:16 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "BufferManager.h" - -BufferManager::BufferManager(int num) : machineNum(num) {} - -BufferManager::~BufferManager(void) { finish(); } - -void -BufferManager::init(void) -{ - taskListImpl = new TaskListInfo; - taskQueueImpl = new TaskQueueInfo; - htaskImpl = new HTaskInfo; - - taskListImpl->init(machineNum*2); - taskQueueImpl->init(TASK_MAX_SIZE*4); - htaskImpl->init(TASK_MAX_SIZE*2); -} - -TaskListPtr -BufferManager::create_taskList(void) -{ - return taskListImpl->create(); -} - -TaskQueuePtr -BufferManager::create_taskQueue(HTaskPtr task) -{ - return taskQueueImpl->create(task); -} - -HTaskPtr -BufferManager::create_task(int cmd) -{ - return htaskImpl->create(cmd); -} - -void -BufferManager::free_taskList(TaskListPtr q) -{ - taskListImpl->free(q); -} - -void -BufferManager::free_taskQueue(TaskQueuePtr q) -{ - taskQueueImpl->free(q); -} - -void -BufferManager::free_task(HTaskPtr task) -{ - htaskImpl->free(task); -} - -void -BufferManager::finish(void) -{ - delete taskListImpl; - delete taskQueueImpl; - delete htaskImpl; -} - -TaskListPtr -BufferManager::clear_taskList(TaskListPtr list) -{ - TaskListPtr p, p1; - - list->length = 0; - - p = list->next; - while (p) { - p1 = p; - p = p->next; - taskListImpl->free(p1); - } - - list->next = NULL; - return list; -}
--- a/TaskManager/kernel/ppe/BufferManager.h Sat Oct 03 10:50:16 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -#ifndef INCLUDED_BUFFER_MANAGER -#define INCLUDED_BUFFER_MANAGER - -#include "types.h" -#include "TaskListInfo.h" -#include "TaskQueueInfo.h" -#include "HTaskInfo.h" - -/*! - * Task Input/Output buffer manager - * - */ - -class BufferManager { -public: - /* constructor */ - BufferManager(int num = 1); - virtual ~BufferManager(void); - - /* variables */ - TaskListInfo *taskListImpl; - TaskQueueInfo *taskQueueImpl; - HTaskInfo *htaskImpl; - - int machineNum; - - /* function */ - virtual void init(void); - - // TaskList - TaskListPtr create_taskList(void); - void free_taskList(TaskListPtr); - TaskListPtr clear_taskList(TaskListPtr); - - // TaskQueue - TaskQueuePtr create_taskQueue(HTaskPtr); - void free_taskQueue(TaskQueuePtr); - - // HTask - HTaskPtr create_task(int cmd); - void free_task(HTaskPtr); - - - void finish(void); -private: -}; - -#endif
--- a/TaskManager/kernel/ppe/TaskListInfo.cc Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskListInfo.cc Sun Oct 04 11:29:50 2009 +0900 @@ -92,3 +92,23 @@ return list; } } + + +TaskListPtr +TaskListInfo::clear_taskList(TaskListPtr list) +{ + TaskListPtr p, p1; + + list->length = 0; + + p = list->next; + while (p) { + p1 = p; + p = p->next; + this->free(p1); + } + + list->next = NULL; + return list; +} +
--- a/TaskManager/kernel/ppe/TaskListInfo.h Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskListInfo.h Sun Oct 04 11:29:50 2009 +0900 @@ -16,6 +16,7 @@ void free(TaskListPtr list); static TaskListPtr append(TaskListPtr list, TaskListPtr q); virtual int extend_pool(int num); + TaskListPtr clear_taskList(TaskListPtr list); protected: /* variables */
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Sun Oct 04 11:29:50 2009 +0900 @@ -42,7 +42,7 @@ { HTaskPtr new_task; - new_task = bufferManager->create_task(cmd); + new_task = htaskImpl->create(cmd); new_task->post_func = noaction; new_task->mimpl = this; @@ -59,8 +59,8 @@ { TaskQueuePtr m, s; - m = bufferManager->create_taskQueue(master); - s = bufferManager->create_taskQueue(slave); + m = taskQueueImpl->create(master); + s = taskQueueImpl->create(slave); master->wait_me = TaskQueue::append(master->wait_me, s); slave->wait_i = TaskQueue::append(slave->wait_i, m); @@ -93,7 +93,7 @@ { TaskQueuePtr q; - q = bufferManager->create_taskQueue(task); + q = taskQueueImpl->create(task); activeTaskQueue = TaskQueue::append(activeTaskQueue, q); } @@ -121,7 +121,7 @@ { notify_wait_taskQueue(task, task->wait_me); task->post_func(task->post_arg); - bufferManager->free_task(task); + htaskImpl->free(task); } /** @@ -150,7 +150,7 @@ { TaskQueuePtr q; - q = bufferManager->create_taskQueue(task); + q = taskQueueImpl->create(task); waitTaskQueue = TaskQueue::append(waitTaskQueue, q); } @@ -183,7 +183,7 @@ while (p != NULL) { p1 = p->next; - bufferManager->free_taskQueue(p); + taskQueueImpl->free(p); p = p1; } } @@ -203,7 +203,7 @@ if (p->task == task) { list = list->next; - bufferManager->free_taskQueue(p); + taskQueueImpl->free(p); } else { p1 = p->next; while (p1 && p1->task && p1->task != task) { @@ -212,7 +212,7 @@ } if (p1) { p->next = p1->next; - bufferManager->free_taskQueue(p1); + taskQueueImpl->free(p1); } } @@ -229,7 +229,7 @@ if (p == q) { list = list->next; - bufferManager->free_taskQueue(p); + taskQueueImpl->free(p); } else { p1 = p->next; while (p1 && p1 != q) { @@ -238,7 +238,7 @@ } if (p1) { p->next = p1->next; - bufferManager->free_taskQueue(p1); + taskQueueImpl->free(p1); } }
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Sun Oct 04 11:29:50 2009 +0900 @@ -2,9 +2,12 @@ #define INCLUDED_TASK_MANAGER_IMPL #include "MailManager.h" -#include "BufferManager.h" #include "ListData.h" #include "Scheduler.h" +#include "TaskListInfo.h" +#include "TaskQueueInfo.h" +#include "HTaskInfo.h" + class TaskManagerImpl { public: @@ -16,7 +19,11 @@ int machineNum; TaskQueuePtr activeTaskQueue; TaskQueuePtr waitTaskQueue; - BufferManager *bufferManager; + + /* variables */ + TaskListInfo *taskListImpl; + TaskQueueInfo *taskQueueImpl; + HTaskInfo *htaskImpl; /* functions */ // system
--- a/TaskManager/kernel/ppe/TaskQueueInfo.h Sat Oct 03 10:50:16 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskQueueInfo.h Sun Oct 04 11:29:50 2009 +0900 @@ -6,8 +6,8 @@ class TaskQueueInfo { public: /* constructor */ - TaskQueueInfo(void); - ~TaskQueueInfo(void); + TaskQueueInfo(); + ~TaskQueueInfo(); /* functions */ int init(int num); @@ -21,7 +21,7 @@ /* functions */ int extend_pool(int num); - void destroy(void); + void destroy(); }; #endif