# HG changeset patch # User Sebastien Jodogne # Date 1571312932 -7200 # Node ID 229ea1389845741056bd9e331139a70b26049c65 # Parent 8d3936f065410509be0a0cdb28f84183d226a5a3 LockingEmitter.cpp diff -r 8d3936f06541 -r 229ea1389845 Framework/Messages/LockingEmitter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Messages/LockingEmitter.cpp Thu Oct 17 13:48:52 2019 +0200 @@ -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 OrthancStone +{ + void LockingEmitter::EmitMessage(IObserver& 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 8d3936f06541 -r 229ea1389845 Framework/Messages/LockingEmitter.h --- a/Framework/Messages/LockingEmitter.h Thu Oct 17 11:27:51 2019 +0200 +++ b/Framework/Messages/LockingEmitter.h Thu Oct 17 13:48:52 2019 +0200 @@ -23,7 +23,9 @@ #include "IMessageEmitter.h" #include "IObservable.h" -#include +#include // For ORTHANC_OVERRIDE + +#include namespace OrthancStone { @@ -43,19 +45,8 @@ IObservable oracleObservable_; public: - virtual void EmitMessage(const IObserver& observer, - const IMessage& message) ORTHANC_OVERRIDE - { - try - { - boost::unique_lock lock(mutex_); - oracleObservable_.EmitMessage(observer, message); - } - catch (Orthanc::OrthancException& e) - { - LOG(ERROR) << "Exception while emitting a message: " << e.What(); - } - } + virtual void EmitMessage(IObserver& observer, + const IMessage& message) ORTHANC_OVERRIDE; class ReaderLock : public boost::noncopyable @@ -66,8 +57,8 @@ public: ReaderLock(LockingEmitter& that) : - that_(that), - lock_(that.mutex_) + that_(that), + lock_(that.mutex_) { } }; @@ -81,8 +72,8 @@ public: WriterLock(LockingEmitter& that) : - that_(that), - lock_(that.mutex_) + that_(that), + lock_(that.mutex_) { } diff -r 8d3936f06541 -r 229ea1389845 Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Thu Oct 17 11:27:51 2019 +0200 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Thu Oct 17 13:48:52 2019 +0200 @@ -401,6 +401,7 @@ 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 )