# HG changeset patch # User Sebastien Jodogne # Date 1354198010 -3600 # Node ID bb8c260c0092b70005bd2acb63fee37e06eba4e7 # Parent 5459f05b4f54d899e51b0a03fb97531e6db224ee fix for windows diff -r 5459f05b4f54 -r bb8c260c0092 OrthancServer/ServerIndex.cpp --- 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(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(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();*/ } diff -r 5459f05b4f54 -r bb8c260c0092 OrthancServer/ServerIndex.h --- 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 +#include #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_;