Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorYuri Gorshenin <y@mmaps.me>2015-03-16 14:55:02 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:39:07 +0300
commit2435c99ad7bf17312e9457692ff0b66332386e2f (patch)
tree5d2d64490138e98ffe2ff43d17b60cbff4b5f104 /base
parente300e2b4313b9eb2fa9d5ef3cdad1216ffec03fa (diff)
[threads] Not explicitly joined threads are detached in dtor.
Diffstat (limited to 'base')
-rw-r--r--base/thread.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/base/thread.cpp b/base/thread.cpp
index a70462c3b2..f63d0ca068 100644
--- a/base/thread.cpp
+++ b/base/thread.cpp
@@ -34,7 +34,16 @@ void RunRoutine(IRoutine * routine)
// Thread wrapper implementation
Thread::Thread() : m_routine(0) {}
-Thread::~Thread() { Join(); }
+Thread::~Thread()
+{
+ // @todo (ygorshenin@): in general, it's not a good practice to
+ // implicitly detach thread since detached threads work in
+ // background, consume system resources and make it hard to reason
+ // about program. Thus, all places where Thread is instantiated
+ // should be fixed to explicitly detach thread.
+ if (m_thread.joinable())
+ m_thread.detach();
+}
bool Thread::Create(IRoutine * pRoutine)
{