Mercurial > hg > orthanc
changeset 220:bb8c260c0092
fix for windows
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Nov 2012 15:06:50 +0100 |
parents | 5459f05b4f54 |
children | e7432706b354 |
files | OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h |
diffstat | 2 files changed, 20 insertions(+), 21 deletions(-) [+] |
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();*/ }
--- a/OrthancServer/ServerIndex.h Thu Nov 29 14:08:27 2012 +0100 +++ b/OrthancServer/ServerIndex.h Thu Nov 29 15:06:50 2012 +0100 @@ -33,6 +33,7 @@ #pragma once #include <boost/thread.hpp> +#include <boost/noncopyable.hpp> #include "../Core/SQLite/Connection.h" #include "../Core/DicomFormat/DicomMap.h" #include "../Core/FileStorage.h" @@ -50,7 +51,7 @@ } - class ServerIndex + class ServerIndex : public boost::noncopyable { private: boost::mutex mutex_;