Mercurial > hg > orthanc
diff OrthancServer/Scheduler/ServerScheduler.cpp @ 1453:c0bdc47165ef
code to warn about possible threading problems
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 Jul 2015 12:26:44 +0200 |
parents | 7b6925b0890d |
children | f967bdf8534e |
line wrap: on
line diff
--- a/OrthancServer/Scheduler/ServerScheduler.cpp Thu Jul 02 11:35:41 2015 +0200 +++ b/OrthancServer/Scheduler/ServerScheduler.cpp Thu Jul 02 12:26:44 2015 +0200 @@ -199,8 +199,25 @@ ServerScheduler::~ServerScheduler() { - finish_ = true; - worker_.join(); + if (!finish_) + { + LOG(ERROR) << "INTERNAL ERROR: ServerScheduler::Finalize() should be invoked manually to avoid mess in the destruction order!"; + Stop(); + } + } + + + void ServerScheduler::Stop() + { + if (!finish_) + { + finish_ = true; + + if (worker_.joinable()) + { + worker_.join(); + } + } }