123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #ifndef __AUTORELEASEPOOL_H__
- #define __AUTORELEASEPOOL_H__
- #include <vector>
- #include <string>
- #include "base/CCRef.h"
- NS_CC_BEGIN
- class CC_DLL AutoreleasePool
- {
- public:
-
- AutoreleasePool();
-
-
- AutoreleasePool(const std::string &name);
-
-
- ~AutoreleasePool();
-
- void addObject(Ref *object);
-
- void clear();
-
- #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
-
- bool isClearing() const { return _isClearing; };
- #endif
-
-
- bool contains(Ref* object) const;
-
- void dump();
-
- private:
-
- std::vector<Ref*> _managedObjectArray;
- std::string _name;
-
- #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
-
- bool _isClearing;
- #endif
- };
- class CC_DLL PoolManager
- {
- public:
- CC_DEPRECATED_ATTRIBUTE static PoolManager* sharedPoolManager() { return getInstance(); }
- static PoolManager* getInstance();
-
- CC_DEPRECATED_ATTRIBUTE static void purgePoolManager() { destroyInstance(); }
- static void destroyInstance();
-
-
- AutoreleasePool *getCurrentPool() const;
- bool isObjectInPools(Ref* obj) const;
- friend class AutoreleasePool;
-
- private:
- PoolManager();
- ~PoolManager();
-
- void push(AutoreleasePool *pool);
- void pop();
-
- static PoolManager* s_singleInstance;
-
- std::vector<AutoreleasePool*> _releasePoolStack;
- };
- /**
- * @endcond
- */
- NS_CC_END
- #endif //__AUTORELEASEPOOL_H__
|