Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 220:bb8c260c0092
fix for windows
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Nov 2012 15:06:50 +0100 |
parents | f276b175dcaf |
children | 4eb0c7ce86c9 |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Thu Nov 29 14:08:27 2012 +0100 +++ b/OrthancServer/ServerIndex.cpp Thu Nov 29 15:06:50 2012 +0100 @@ -166,23 +166,9 @@ static void FlushThread(DatabaseWrapper* db, - boost::mutex* mutex) + boost::mutex* mutex, + unsigned int sleep) { - // By default, wait for 10 seconds before flushing - unsigned int sleep = 10; - - { - boost::mutex::scoped_lock lock(*mutex); - std::string s = db->GetGlobalProperty(GlobalProperty_FlushSleep); - try - { - sleep = boost::lexical_cast<unsigned int>(s); - } - catch (boost::bad_lexical_cast&) - { - } - } - LOG(INFO) << "Starting the database flushing thread (sleep = " << sleep << ")"; while (1) @@ -195,7 +181,7 @@ ServerIndex::ServerIndex(FileStorage& fileStorage, - const std::string& dbPath) + const std::string& dbPath) : mutex_() { listener_.reset(new Internals::ServerIndexListener(fileStorage)); @@ -218,15 +204,27 @@ db_.reset(new DatabaseWrapper(p.string() + "/index", *listener_)); } - flushThread_ = boost::thread(FlushThread, db_.get(), &mutex_); + unsigned int sleep; + try + { + std::string sleepString = db_->GetGlobalProperty(GlobalProperty_FlushSleep); + sleep = boost::lexical_cast<unsigned int>(sleepString); + } + catch (boost::bad_lexical_cast&) + { + // By default, wait for 10 seconds before flushing + sleep = 10; + } + + flushThread_ = boost::thread(FlushThread, db_.get(), &mutex_, sleep); } ServerIndex::~ServerIndex() { LOG(INFO) << "Stopping the database flushing thread"; - flushThread_.interrupt(); - flushThread_.join(); + /*flushThread_.terminate(); + flushThread_.join();*/ }