Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.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 | 0ac74fa21db8 |
children | f967bdf8534e |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Thu Jul 02 11:35:41 2015 +0200 +++ b/OrthancServer/ServerIndex.cpp Thu Jul 02 12:26:44 2015 +0200 @@ -564,23 +564,39 @@ } + ServerIndex::~ServerIndex() { - done_ = true; - - if (db_.HasFlushToDisk() && - flushThread_.joinable()) + if (!done_) { - flushThread_.join(); - } - - if (unstableResourcesMonitorThread_.joinable()) - { - unstableResourcesMonitorThread_.join(); + LOG(ERROR) << "INTERNAL ERROR: ServerIndex::Stop() should be invoked manually to avoid mess in the destruction order!"; + Stop(); } } + + void ServerIndex::Stop() + { + if (!done_) + { + done_ = true; + + if (db_.HasFlushToDisk() && + flushThread_.joinable()) + { + flushThread_.join(); + } + + if (unstableResourcesMonitorThread_.joinable()) + { + unstableResourcesMonitorThread_.join(); + } + } + } + + + StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, const DicomMap& dicomSummary, const Attachments& attachments,