diff options
Diffstat (limited to 'src/threadengine.cpp')
-rw-r--r-- | src/threadengine.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/threadengine.cpp b/src/threadengine.cpp index 36a73d324..0ac049c38 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -2,16 +2,39 @@ ThreadEngine threadEngine; +/** Check for finished threads + */ +void ThreadEngine::Process() +{ + for (unsigned i = this->threads.size(); i > 0; --i) + { + Thread *t = this->threads[i - 1]; + + if (t->GetExitState()) + { + t->Join(); + delete t; + } + } +} + /** Threads constructor */ Thread::Thread() : Exit(false) { + threadEngine.threads.push_back(this); } /** Threads destructor */ Thread::~Thread() { + std::vector<Thread *>::iterator it = std::find(threadEngine.threads.begin(), threadEngine.threads.end(), this); + + if (it != threadEngine.threads.end()) + { + threadEngine.threads.erase(it); + } } /** Sets the exit state as true informing the thread we want it to shut down |