物件池只是管理指標和物件用的,並不高效
#include #include#include
#include
#include
#include
#include
#include
#include
"commonstruct.h
"#include
"inputmonitor.h
"#include
"outputmonitor.h
"#include
"messageblock.h
"#include
"messageblockcache.h
"#include
"bufqueue.h
"#include
"timekit.h
"#include
"duplexqueue.h
"#include
"objectpool.h"//
duplexlist* _recv_net_msg_queue = null;
//duplexlist* _send_net_msg_queue = null;
duplexqueue _queue;
void* process(void*arg)
}return
null;
}void
functions()
int j=0
;
for(std::map::iterator iter =v.begin();
iter !=v.end();
iter ++)
}class
testobject
~testobject()
private
:
inti;
list
_test;
char cc[100
];};
template
class
cobjectpool
}~cobjectpool()
void pop(cobject *&c)
else
pop(c);}}
void push(cobject *c)
private
: std::vector
_list;
};template
class
cobjectpoolq
}~cobjectpoolq()
void pop(cobject *&c)
else
pop(c);}}
void push(cobject *c)
private
: std::queue
_list;
};int main(int argc,char*ar**)
for(std::list::iterator iter = _list.begin() ; iter != _list.end() ; iter ++)
long
long
int end =timekit::get_tick();
printf(
"%ld
",(end -start));
return0;
}
有興趣的同學可以測試下上面的**!
stl的vector 和 queue 相對高效,比list快不少,用vector和queue 維護的物件池,已經和裸指標管理效能相當。
物件池只是管理指標和物件用的
物件池只是管理指標和物件用的,並不高效 include include include include include include include include include commonstruct.h include inputmonitor.h include outputmonito...
CocosCreator物件池管理
import from resourcemanager const cc.decorator ccclass export class nodepoolmanager 物件池存 param pool 物件池 param num 數量 param pre 預設 static poolput pool ...
物件池管理的學習
知識點 scriptableobject 可以實現建立物件時指令碼無需依賴於遊戲物件,所建立物件也要繼承該介面。assetdatabase 操作unity資源的介面。editor類 using unityengine using system.collections using unityedito...