diff TaskManager/kernel/ppe/QueueInfo.h @ 958:58ff7b6fdbce

add freeOnce()
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 04 Aug 2010 17:42:36 +0900
parents 15026ebf7a17
children 02f1a707ee82
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/QueueInfo.h	Wed Aug 04 17:07:37 2010 +0900
+++ b/TaskManager/kernel/ppe/QueueInfo.h	Wed Aug 04 17:42:36 2010 +0900
@@ -14,6 +14,9 @@
     T *next;
     T *prev;
 
+    void initOnce();  // to initialize object in pool
+    void freeOnce();  // to destroy object in pool
+
     // virual void init();
 };
 #endif
@@ -22,9 +25,17 @@
 
 public:
     /* constructor */
+
+    /** 
+	singleton constructor 
+	use this in non initialize envrionment is wrong.
+    */
     QueueInfo<T>(){
 	queueInfoInit();
     }
+    /** 
+	normal constructor requires
+    */
     QueueInfo<T>(QueueInfo<T> *p) {
 	queueInfoInit();
 	queuePool = p;
@@ -58,6 +69,7 @@
 private:
     /* variables */
 
+    /* we cannot use static in template */
     /* static */ QueueInfo<T> *queuePool;
     T* first;
     T* last;
@@ -76,9 +88,15 @@
 #include <stdlib.h>
 
 
-// Singleton T Pool
-// you have to define it at where you want to use.
-// template<typename T>static QueueInfo<T> QueueInfo<T>::queuePool;   
+/** 
+    singleton constructor 
+    all queueInfo should share this as a pool.
+
+    exteren QueueInfo<H> pool;
+    QueueInfo<H> pool = new QueueInfo<H>();
+
+    use this in non initialize envrionment is wrong.
+*/
 
 template<typename T>void QueueInfo<T>::queueInfoInit() {
     // 最初の一つは自分
@@ -92,11 +110,16 @@
     for(T * p = queuePool->waiter; p; ) {
 	T * next = p->waiter;
 	p->waiter = NULL;
+	p->freeOnce();
 	free(p);
 	p = next;
     }
 }
 
+/**
+    all pools are shared among QueueInfo (separated by size and type).
+    it automatically extended by 64.
+ */
 template<typename T>int
 QueueInfo<T>::extend_pool(int num)
 {