# HG changeset patch # User Sebastien Jodogne # Date 1575802666 -3600 # Node ID 05d05cba0f4fbe33ecdbe4523a94cf2bc3fad81f # Parent 16738485e45784efdc3d2f930ed33b538b34966a explicitely tagging LockingEmitter as deprecated diff -r 16738485e457 -r 05d05cba0f4f Applications/Generic/GuiAdapter.cpp --- a/Applications/Generic/GuiAdapter.cpp Sun Dec 08 11:45:09 2019 +0100 +++ b/Applications/Generic/GuiAdapter.cpp Sun Dec 08 11:57:46 2019 +0100 @@ -31,7 +31,7 @@ #endif #if ORTHANC_ENABLE_THREADS == 1 -# include "../../Framework/Messages/LockingEmitter.h" +# include "../../Framework/Deprecated/Messages/LockingEmitter.h" #endif namespace OrthancStone diff -r 16738485e457 -r 05d05cba0f4f Applications/Generic/GuiAdapter.h --- a/Applications/Generic/GuiAdapter.h Sun Dec 08 11:45:09 2019 +0100 +++ b/Applications/Generic/GuiAdapter.h Sun Dec 08 11:57:46 2019 +0100 @@ -43,8 +43,8 @@ #include "../../Framework/StoneException.h" -#if ORTHANC_ENABLE_THREADS != 1 -# include "../../Framework/Messages/LockingEmitter.h" +#if ORTHANC_ENABLE_THREADS == 1 +# include "../../Framework/Deprecated/Messages/LockingEmitter.h" #endif #include @@ -95,11 +95,6 @@ struct GuiAdapterWheelEvent; struct GuiAdapterKeyboardEvent; - namespace Deprecated - { - class LockingEmitter; - } - #if 1 typedef bool (*OnMouseEventFunc)(std::string canvasId, const GuiAdapterMouseEvent* mouseEvent, void* userData); typedef bool (*OnMouseWheelFunc)(std::string canvasId, const GuiAdapterWheelEvent* wheelEvent, void* userData); diff -r 16738485e457 -r 05d05cba0f4f Framework/Deprecated/Loaders/LoaderCache.cpp --- a/Framework/Deprecated/Loaders/LoaderCache.cpp Sun Dec 08 11:45:09 2019 +0100 +++ b/Framework/Deprecated/Loaders/LoaderCache.cpp Sun Dec 08 11:57:46 2019 +0100 @@ -64,7 +64,7 @@ } #else LoaderCache::LoaderCache(OrthancStone::ThreadedOracle& oracle, - OrthancStone::Deprecated::LockingEmitter& lockingEmitter) + LockingEmitter& lockingEmitter) : oracle_(oracle) , lockingEmitter_(lockingEmitter) { @@ -97,7 +97,7 @@ #if ORTHANC_ENABLE_WASM == 1 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, oracle_)); #else - OrthancStone::Deprecated::LockingEmitter::WriterLock lock(lockingEmitter_); + LockingEmitter::WriterLock lock(lockingEmitter_); loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, lock.GetOracleObservable())); #endif // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : loader = " << loader.get(); @@ -166,7 +166,7 @@ #if ORTHANC_ENABLE_WASM == 1 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, oracle_)); #else - OrthancStone::Deprecated::LockingEmitter::WriterLock lock(lockingEmitter_); + LockingEmitter::WriterLock lock(lockingEmitter_); loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, lock.GetOracleObservable())); #endif loader->LoadInstance(instanceUuid); @@ -267,7 +267,7 @@ #if ORTHANC_ENABLE_WASM == 1 loader.reset(new DicomStructureSetLoader(oracle_, oracle_)); #else - OrthancStone::Deprecated::LockingEmitter::WriterLock lock(lockingEmitter_); + LockingEmitter::WriterLock lock(lockingEmitter_); loader.reset(new DicomStructureSetLoader(oracle_, lock.GetOracleObservable())); #endif loader->LoadInstance(inInstanceUuid, initiallyVisibleStructures); @@ -363,7 +363,7 @@ void LoaderCache::ClearCache() { #if ORTHANC_ENABLE_WASM != 1 - OrthancStone::Deprecated::LockingEmitter::WriterLock lock(lockingEmitter_); + LockingEmitter::WriterLock lock(lockingEmitter_); #endif //#ifndef NDEBUG diff -r 16738485e457 -r 05d05cba0f4f Framework/Deprecated/Loaders/LoaderCache.h --- a/Framework/Deprecated/Loaders/LoaderCache.h Sun Dec 08 11:45:09 2019 +0100 +++ b/Framework/Deprecated/Loaders/LoaderCache.h Sun Dec 08 11:57:46 2019 +0100 @@ -20,7 +20,7 @@ #pragma once -#include "../../Messages/LockingEmitter.h" +#include "../Messages/LockingEmitter.h" #include "../../Volumes/DicomVolumeImageMPRSlicer.h" #include "OrthancSeriesVolumeProgressiveLoader.h" #include "OrthancMultiframeVolumeLoader.h" @@ -49,7 +49,7 @@ #if ORTHANC_ENABLE_WASM == 1 LoaderCache(OrthancStone::WebAssemblyOracle& oracle); #else - LoaderCache(OrthancStone::ThreadedOracle& oracle, OrthancStone::Deprecated::LockingEmitter& lockingEmitter); + LoaderCache(OrthancStone::ThreadedOracle& oracle, LockingEmitter& lockingEmitter); #endif boost::shared_ptr @@ -84,7 +84,7 @@ OrthancStone::WebAssemblyOracle& oracle_; #else OrthancStone::ThreadedOracle& oracle_; - OrthancStone::Deprecated::LockingEmitter& lockingEmitter_; + LockingEmitter& lockingEmitter_; #endif std::map > diff -r 16738485e457 -r 05d05cba0f4f Framework/Deprecated/Messages/LockingEmitter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Deprecated/Messages/LockingEmitter.cpp Sun Dec 08 11:57:46 2019 +0100 @@ -0,0 +1,40 @@ +/** + * Stone of Orthanc + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2019 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + **/ + +#include "LockingEmitter.h" + +#include + +namespace Deprecated +{ + void LockingEmitter::EmitMessage(boost::weak_ptr observer, + const OrthancStone::IMessage& message) + { + try + { + boost::unique_lock lock(mutex_); + oracleObservable_.EmitMessage(observer, message); + } + catch (Orthanc::OrthancException& e) + { + LOG(ERROR) << "Exception while emitting a message: " << e.What(); + } + } +} diff -r 16738485e457 -r 05d05cba0f4f Framework/Deprecated/Messages/LockingEmitter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Deprecated/Messages/LockingEmitter.h Sun Dec 08 11:57:46 2019 +0100 @@ -0,0 +1,89 @@ +/** + * Stone of Orthanc + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2019 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + **/ + +#pragma once + +#include +#include + +#include "../../Messages/IMessageEmitter.h" +#include "../../Messages/IObservable.h" + +#include // For ORTHANC_OVERRIDE + +#include + +namespace Deprecated +{ + /** + * This class is used when using the ThreadedOracle : since messages + * can be sent from multiple Oracle threads, this IMessageEmitter + * implementation serializes the callbacks. + * + * The internal mutex used in Oracle messaging can also be used to + * protect the application data. Thus, this class can be used as a single + * application-wide mutex. + */ + class LockingEmitter : public OrthancStone::IMessageEmitter + { + private: + boost::shared_mutex mutex_; + OrthancStone::IObservable oracleObservable_; + + public: + virtual void EmitMessage(boost::weak_ptr observer, + const OrthancStone::IMessage& message) ORTHANC_OVERRIDE; + + + class ReaderLock : public boost::noncopyable + { + private: + LockingEmitter& that_; + boost::shared_lock lock_; + + public: + ReaderLock(LockingEmitter& that) : + that_(that), + lock_(that.mutex_) + { + } + }; + + + class WriterLock : public boost::noncopyable + { + private: + LockingEmitter& that_; + boost::unique_lock lock_; + + public: + WriterLock(LockingEmitter& that) : + that_(that), + lock_(that.mutex_) + { + } + + OrthancStone::IObservable& GetOracleObservable() + { + return that_.oracleObservable_; + } + }; + }; +} diff -r 16738485e457 -r 05d05cba0f4f Framework/Messages/LockingEmitter.cpp --- a/Framework/Messages/LockingEmitter.cpp Sun Dec 08 11:45:09 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2019 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - -#include "LockingEmitter.h" - -#include - -namespace OrthancStone -{ - namespace Deprecated - { - void LockingEmitter::EmitMessage(boost::weak_ptr observer, - const IMessage& message) - { - try - { - boost::unique_lock lock(mutex_); - oracleObservable_.EmitMessage(observer, message); - } - catch (Orthanc::OrthancException& e) - { - LOG(ERROR) << "Exception while emitting a message: " << e.What(); - } - } - } -} diff -r 16738485e457 -r 05d05cba0f4f Framework/Messages/LockingEmitter.h --- a/Framework/Messages/LockingEmitter.h Sun Dec 08 11:45:09 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2019 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - -#pragma once - -#include -#include - -#include "IMessageEmitter.h" -#include "IObservable.h" - -#include // For ORTHANC_OVERRIDE - -#include - -namespace OrthancStone -{ - namespace Deprecated - { - /** - * This class is used when using the ThreadedOracle : since messages - * can be sent from multiple Oracle threads, this IMessageEmitter - * implementation serializes the callbacks. - * - * The internal mutex used in Oracle messaging can also be used to - * protect the application data. Thus, this class can be used as a single - * application-wide mutex. - */ - class LockingEmitter : public IMessageEmitter - { - private: - boost::shared_mutex mutex_; - IObservable oracleObservable_; - - public: - virtual void EmitMessage(boost::weak_ptr observer, - const IMessage& message) ORTHANC_OVERRIDE; - - - class ReaderLock : public boost::noncopyable - { - private: - LockingEmitter& that_; - boost::shared_lock lock_; - - public: - ReaderLock(LockingEmitter& that) : - that_(that), - lock_(that.mutex_) - { - } - }; - - - class WriterLock : public boost::noncopyable - { - private: - LockingEmitter& that_; - boost::unique_lock lock_; - - public: - WriterLock(LockingEmitter& that) : - that_(that), - lock_(that.mutex_) - { - } - - IObservable& GetOracleObservable() - { - return that_.oracleObservable_; - } - }; - }; - } -} diff -r 16738485e457 -r 05d05cba0f4f Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Sun Dec 08 11:45:09 2019 +0100 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Sun Dec 08 11:57:46 2019 +0100 @@ -339,6 +339,13 @@ ) endif() + if (ENABLE_THREADS) + list(APPEND ORTHANC_STONE_SOURCES + ${ORTHANC_STONE_ROOT}/Framework/Deprecated/Messages/LockingEmitter.cpp + ${ORTHANC_STONE_ROOT}/Framework/Deprecated/Messages/LockingEmitter.h + ) + endif() + list(APPEND ORTHANC_STONE_SOURCES ${ORTHANC_STONE_ROOT}/Applications/IStoneApplication.h ${ORTHANC_STONE_ROOT}/Applications/StoneApplicationContext.cpp @@ -428,8 +435,6 @@ if (ENABLE_THREADS) list(APPEND ORTHANC_STONE_SOURCES - ${ORTHANC_STONE_ROOT}/Framework/Messages/LockingEmitter.cpp - ${ORTHANC_STONE_ROOT}/Framework/Messages/LockingEmitter.h ${ORTHANC_STONE_ROOT}/Framework/Oracle/ThreadedOracle.cpp ${ORTHANC_STONE_ROOT}/Framework/Oracle/GenericOracleRunner.cpp )