mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 06:53:01 +02:00
add method to clear the NodeList
This commit is contained in:
parent
4f0e472868
commit
12697c6b14
2 changed files with 17 additions and 0 deletions
|
@ -70,6 +70,8 @@ NodeList::NodeList(char newOwnerType, unsigned int newSocketListenPort) :
|
||||||
NodeList::~NodeList() {
|
NodeList::~NodeList() {
|
||||||
delete _nodeTypesOfInterest;
|
delete _nodeTypesOfInterest;
|
||||||
|
|
||||||
|
clear();
|
||||||
|
|
||||||
// stop the spawned threads, if they were started
|
// stop the spawned threads, if they were started
|
||||||
stopSilentNodeRemovalThread();
|
stopSilentNodeRemovalThread();
|
||||||
|
|
||||||
|
@ -209,6 +211,19 @@ int NodeList::getNumAliveNodes() const {
|
||||||
return numAliveNodes;
|
return numAliveNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeList::clear() {
|
||||||
|
// delete all of the nodes in the list, set the pointers back to NULL and the number of nodes to 0
|
||||||
|
for (int i = 0; i < _numNodes; i++) {
|
||||||
|
Node** nodeBucket = _nodeBuckets[i / NODES_PER_BUCKET];
|
||||||
|
Node* node = nodeBucket[i % NODES_PER_BUCKET];
|
||||||
|
|
||||||
|
delete node;
|
||||||
|
node = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_numNodes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
||||||
delete _nodeTypesOfInterest;
|
delete _nodeTypesOfInterest;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
int size() { return _numNodes; }
|
int size() { return _numNodes; }
|
||||||
int getNumAliveNodes() const;
|
int getNumAliveNodes() const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
void lock() { pthread_mutex_lock(&mutex); }
|
void lock() { pthread_mutex_lock(&mutex); }
|
||||||
void unlock() { pthread_mutex_unlock(&mutex); }
|
void unlock() { pthread_mutex_unlock(&mutex); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue