Added a DeleteHandler into osg::Referenced so that it can delete objects

via a seperate delete handler.  Useful for making unref()/ref() thread safe if
the users needs to address this issue.
This commit is contained in:
Robert Osfield
2002-12-16 10:25:31 +00:00
parent cb87e7b3bc
commit 884b2730e8
5 changed files with 96 additions and 22 deletions

View File

@@ -1,28 +1,12 @@
#include <osg/Object>
#include <osg/Notify>
#include <typeinfo>
using namespace osg;
#ifdef OSG_COMPILE_UNIT_TESTS
int Referenced::_createdCount = 0;
int Referenced::_deletedCount = 0;
#endif
Referenced::~Referenced()
namespace osg
{
if (_refCount>0)
{
notify(WARN)<<"Warning: deleting still referenced object "<<this<<" of type '"<<typeid(this).name()<<"'"<<std::endl;
notify(WARN)<<" the final reference count was "<<_refCount<<", memory corruption possible."<<std::endl;
}
#ifdef OSG_COMPILE_UNIT_TESTS
_deletedCount ++;
#endif
}
Object::Object(const Object& obj,const CopyOp& copyop):
Referenced(),
_dataVariance(obj._dataVariance),
_userData(copyop(obj._userData.get())) {}
}; // end of namespace osg