Mercurial > hg > Members > kono > Cerium
changeset 818:19c6cdeb23d6
too few template-parameter-lists
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 23 May 2010 10:55:25 +0900 |
parents | 4e8fc627ed33 |
children | 5b18db249729 |
files | TaskManager/kernel/ppe/QueueInfo.h TaskManager/kernel/ppe/Threads.h example/task_queue/Makefile.def example/task_queue/Makefile.macosx example/task_queue/main.cc |
diffstat | 5 files changed, 50 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/QueueInfo.h Sun May 23 09:43:27 2010 +0900 +++ b/TaskManager/kernel/ppe/QueueInfo.h Sun May 23 10:55:25 2010 +0900 @@ -3,19 +3,21 @@ #include "base.h" -template <typename T> class Queue { +#if 0 +template <typename T> class Queue : T { public: - Queue<T>(); + T(); T *waiter; T *next; T *prev; - void init(); + // virual void init(); }; +#endif -template <typename T> class QueueInfo : public Queue<T> { +template <typename T> class QueueInfo : public T { public: /* constructor */ @@ -24,32 +26,32 @@ BASE_NEW_DELETE(QueueInfo); /* functions */ - Queue<T> *create(); + T *create(); - void free_(Queue<T> *queue); + void free_(T *queue); - void addFirst(Queue<T>* e); - void addLast(Queue<T>* e); - Queue<T>* getFirst(); - Queue<T>* getLast(); - int remove(Queue<T>* e); - Queue<T>* poll(); - void moveToFirst(Queue<T>* e); // or use(); - Queue<T>* get(int index); - Queue<T>* find(Queue<T> *task); + void addFirst(T* e); + void addLast(T* e); + T* getFirst(); + T* getLast(); + int remove(T* e); + T* poll(); + void moveToFirst(T* e); // or use(); + T* get(int index); + T* find(T *task); int empty(); void freePool() ; // Iterator - Queue<T>* getNext(Queue<T>* q) ; + T* getNext(T* q) ; int length(); private: /* variables */ static QueueInfo<T> queuePool; - Queue<T>* first; - Queue<T>* last; + T* first; + T* last; /* functions */ int extend_pool(int num); @@ -77,8 +79,8 @@ template<typename T>void QueueInfo<T>::freePool() { - for(Queue<T> * p = queuePool.waiter; p; ) { - Queue<T> * next = p->waiter; + for(T * p = queuePool.waiter; p; ) { + T * next = p->waiter; p->waiter = NULL; free(p); p = next; @@ -88,14 +90,14 @@ template<typename T>int QueueInfo<T>::extend_pool(int num) { - Queue<T> * q = (Queue<T> *)malloc(sizeof(Queue<T>)*(num+1)); + T * q = (T *)malloc(sizeof(T)*(num+1)); // First Queue is previous pool q->waiter = this->waiter; this->waiter = q; q++; /* Connect all free queue in the pool */ - Queue<T> * p = q; + T * p = q; for (; num-- > 0; p++) { p->waiter = NULL; queuePool.addLast(p); @@ -109,10 +111,10 @@ * * @param [cmd] タスクコマンド */ -template<typename T>Queue<T> * +template<typename T>T * QueueInfo<T>::create() { - Queue<T> * q = queuePool.poll(); + T * q = queuePool.poll(); if (! q) { queuePool.extend_pool(64); q = queuePool.poll(); @@ -123,7 +125,7 @@ template<typename T>void -QueueInfo<T>::free_(Queue<T> * q) +QueueInfo<T>::free_(T * q) { q->waiter = NULL; queuePool.addLast(q); @@ -139,7 +141,7 @@ 最初の1個は特別扱いなので、それの後に追加していく */ template<typename T>void -QueueInfo<T>::addFirst(Queue<T>* e) +QueueInfo<T>::addFirst(T* e) { e->prev = first; e->next = first->next; @@ -148,7 +150,7 @@ } template<typename T>void -QueueInfo<T>::addLast(Queue<T>* e) +QueueInfo<T>::addLast(T* e) { #ifdef CHECK if (find(e)) { @@ -163,14 +165,14 @@ last = e; } -template<typename T>Queue<T>* +template<typename T>T* QueueInfo<T>::getFirst() { if (empty()) return NULL; return first->next; } -template<typename T>Queue<T>* +template<typename T>T* QueueInfo<T>::getLast() { if (empty()) return NULL; @@ -178,7 +180,7 @@ } template<typename T>int -QueueInfo<T>::remove(Queue<T>* e) +QueueInfo<T>::remove(T* e) { #ifdef CHECK if (!find(e)) { @@ -207,10 +209,10 @@ リストの先頭を取得および削除する。リストが空の場合は NULL を返す。 */ -template<typename T>Queue<T>* +template<typename T>T* QueueInfo<T>::poll() { - Queue<T>* e = first->next; + T* e = first->next; if (e == this) { return NULL; } @@ -219,7 +221,7 @@ } template<typename T>void -QueueInfo<T>::moveToFirst(Queue<T>* e) +QueueInfo<T>::moveToFirst(T* e) { remove(e); addFirst(e); @@ -230,10 +232,10 @@ 要素数を超えた位置を指定した場合 NULL を返す。 */ -template<typename T>Queue<T>* +template<typename T>T* QueueInfo<T>::get(int index) { - Queue<T>* e = first->next; + T* e = first->next; for (int i = 0; i < index; i++) { if (e == this) return NULL; e = e->next; @@ -241,10 +243,10 @@ return e; } -template<typename T>Queue<T>* -QueueInfo<T>::find(Queue<T>* task) +template<typename T>T* +QueueInfo<T>::find(T* task) { - Queue<T>* e = first->next; + T* e = first->next; for(;;) { if (e == this) return NULL; if (e == task) break; @@ -259,8 +261,8 @@ return this->next == this; } -template<typename T>Queue<T>* -QueueInfo<T>::getNext(Queue<T>* q) +template<typename T>T* +QueueInfo<T>::getNext(T* q) { if (q->next==this) return NULL; return q->next; @@ -271,7 +273,7 @@ { int i = 1; if (empty()) return 0; - Queue<T>* e = first; + T* e = first; while((e = e->next) != this ) i++; return i; }
--- a/TaskManager/kernel/ppe/Threads.h Sun May 23 09:43:27 2010 +0900 +++ b/TaskManager/kernel/ppe/Threads.h Sun May 23 10:55:25 2010 +0900 @@ -18,7 +18,6 @@ /* variables */ pthread_t *threads; - thread_arg_t *args; int cpu_num; };
--- a/example/task_queue/Makefile.def Sun May 23 09:43:27 2010 +0900 +++ b/example/task_queue/Makefile.def Sun May 23 10:55:25 2010 +0900 @@ -1,10 +1,10 @@ TARGET = task_queue # include/library path -# ex: macosx +# ex macosx #CERIUM = /Users/gongo/Source/Cerium -# ex: linux/ps3 +# ex linux/ps3 CERIUM = ../../../Cerium CC = g++
--- a/example/task_queue/Makefile.macosx Sun May 23 09:43:27 2010 +0900 +++ b/example/task_queue/Makefile.macosx Sun May 23 10:55:25 2010 +0900 @@ -12,7 +12,7 @@ TASK_OBJS = $(TASK_SRCS:.cc=.o) LIBS += -lFifoManager `sdl-config --libs` -CC += -m64 +CC += -m32 .SUFFIXES: .cc .o
--- a/example/task_queue/main.cc Sun May 23 09:43:27 2010 +0900 +++ b/example/task_queue/main.cc Sun May 23 10:55:25 2010 +0900 @@ -11,6 +11,9 @@ extern TaskManager *manager; +extern void queueInfoTest(int count); + + const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\ -cpu Number of SPE (default 1) \n\ -count Number of task is print \"Hello, World!!\""; @@ -108,6 +111,7 @@ // ppe/task_init.cc task_init(); + queueInfoTest(count); hello_init(manager); return 0;