最近看的android代码,看到一个模板实现的单例模式,相当易用。在framework/base/utils/include/singleton.h直接继承即可。做个记录template <typename TYPE>class Singleton{public: static TYPE& getInstance() { Mutex::Autolock _l(sLock); TYPE* instance = sInstance; if (instance == 0) { instance = new TYPE(); ... Read More
posted @ 2012-07-10 11:42 mr_nop Views(323) Comments(0) Diggs(0) Edit