unhook node bag from element notifications on shutdown to speed up cleanup

This commit is contained in:
ZappoMan 2014-04-21 15:45:12 -07:00
parent 779b5a6827
commit f3aa9d3b8f
3 changed files with 12 additions and 1 deletions

View file

@ -62,6 +62,7 @@ void OctreeQueryNode::nodeKilled() {
// while the thread actually shuts down // while the thread actually shuts down
_octreeSendThread->setIsShuttingDown(); _octreeSendThread->setIsShuttingDown();
} }
nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications
} }
void OctreeQueryNode::forceNodeShutdown() { void OctreeQueryNode::forceNodeShutdown() {

View file

@ -16,13 +16,20 @@ OctreeElementBag::OctreeElementBag() :
_bagElements() _bagElements()
{ {
OctreeElement::addDeleteHook(this); OctreeElement::addDeleteHook(this);
_hooked = true;
}; };
OctreeElementBag::~OctreeElementBag() { OctreeElementBag::~OctreeElementBag() {
OctreeElement::removeDeleteHook(this); unhookNotifications();
deleteAll(); deleteAll();
} }
void OctreeElementBag::unhookNotifications() {
if (_hooked) {
OctreeElement::removeDeleteHook(this);
}
}
void OctreeElementBag::elementDeleted(OctreeElement* element) { void OctreeElementBag::elementDeleted(OctreeElement* element) {
qDebug() << "OctreeElementBag::elementDeleted()..."; qDebug() << "OctreeElementBag::elementDeleted()...";
remove(element); // note: remove can safely handle nodes that aren't in it, so we don't need to check contains() remove(element); // note: remove can safely handle nodes that aren't in it, so we don't need to check contains()

View file

@ -36,8 +36,11 @@ public:
void deleteAll(); void deleteAll();
virtual void elementDeleted(OctreeElement* element); virtual void elementDeleted(OctreeElement* element);
void unhookNotifications();
private: private:
QSet<OctreeElement*> _bagElements; QSet<OctreeElement*> _bagElements;
bool _hooked;
}; };
#endif // hifi_OctreeElementBag_h #endif // hifi_OctreeElementBag_h