Huge engine change, replace all std::shared_ptrs

Create a new shared pointer type stdext::shared_object_ptr and stdext::shared_obj
using boost::intrusive_ptr

Advantages:
 * half memory usage
 * faster and lightweight

Disadvantages:
 * using weak_ptr is not supported anymore
 * compiling seems slower
This commit is contained in:
Eduardo Bart
2012-07-29 00:34:40 -03:00
parent 3ca6494343
commit e0431021b5
81 changed files with 314 additions and 336 deletions

View File

@@ -33,7 +33,7 @@ enum {
BINARYTREE_NODE_END = 0xFF
};
class BinaryTree
class BinaryTree : public stdext::shared_object
{
public:
BinaryTree(const FileStreamPtr& fin);

View File

@@ -33,13 +33,11 @@ class ScheduledEvent;
class FileStream;
class BinaryTree;
typedef std::shared_ptr<Module> ModulePtr;
typedef std::shared_ptr<Event> EventPtr;
typedef std::shared_ptr<ScheduledEvent> ScheduledEventPtr;
typedef std::shared_ptr<FileStream> FileStreamPtr;
typedef std::shared_ptr<BinaryTree> BinaryTreePtr;
typedef std::weak_ptr<BinaryTree> BinaryTreeWeakPtr;
typedef stdext::shared_object_ptr<Module> ModulePtr;
typedef stdext::shared_object_ptr<Event> EventPtr;
typedef stdext::shared_object_ptr<ScheduledEvent> ScheduledEventPtr;
typedef stdext::shared_object_ptr<FileStream> FileStreamPtr;
typedef stdext::shared_object_ptr<BinaryTree> BinaryTreePtr;
typedef std::vector<BinaryTreePtr> BinaryTreeVec;

View File

@@ -61,7 +61,7 @@ public:
void addString(const std::string& v);
BinaryTreePtr makeTree();
FileStreamPtr asFileStream() { return std::static_pointer_cast<FileStream>(shared_from_this()); }
FileStreamPtr asFileStream() { return self_cast<FileStream>(); }
private:
void checkWrite();

View File

@@ -56,7 +56,7 @@ public:
int getAutoLoadPriority() { return m_autoLoadPriority; }
// @dontbind
ModulePtr asModule() { return std::static_pointer_cast<Module>(shared_from_this()); }
ModulePtr asModule() { return self_cast<Module>(); }
protected:
void discover(const OTMLNodePtr& moduleNode);

View File

@@ -46,7 +46,7 @@ void ModuleManager::discoverModules()
if(boost::ends_with(moduleFile, ".otmod")) {
ModulePtr module = discoverModule("/" + moduleDir + "/" + moduleFile);
if(module && module->isAutoLoad())
m_autoLoadModules.insert(make_pair(module->getAutoLoadPriority(), module));
m_autoLoadModules.insert(std::make_pair(module->getAutoLoadPriority(), module));
}
}
}