annotate Framework/Deprecated/Messages/LockingEmitter.h @ 1279:7ec8fea061b9 broker

integration mainline->broker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Feb 2020 15:20:08 +0100
parents Framework/Messages/LockingEmitter.h@2d8ab34c8c91 Framework/Messages/LockingEmitter.h@0ca50d275b9a
children 30deba7bc8e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1271
0ca50d275b9a upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1226
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 #pragma once
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
1071
6dd90b8d1589 Fixes related to refactorings in viewports.
Benjamin Golinvaux <bgo@osimis.io>
parents: 852
diff changeset
23 #include <Core/Enumerations.h>
6dd90b8d1589 Fixes related to refactorings in viewports.
Benjamin Golinvaux <bgo@osimis.io>
parents: 852
diff changeset
24 #include <Core/OrthancException.h>
6dd90b8d1589 Fixes related to refactorings in viewports.
Benjamin Golinvaux <bgo@osimis.io>
parents: 852
diff changeset
25
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
26 #include "../../Messages/IMessageEmitter.h"
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
27 #include "../../Messages/IObservable.h"
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28
1074
229ea1389845 LockingEmitter.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1059
diff changeset
29 #include <Core/Enumerations.h> // For ORTHANC_OVERRIDE
229ea1389845 LockingEmitter.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1059
diff changeset
30
229ea1389845 LockingEmitter.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1059
diff changeset
31 #include <boost/thread/shared_mutex.hpp>
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
33 namespace Deprecated
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 {
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
35 /**
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
36 * This class is used when using the ThreadedOracle : since messages
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
37 * can be sent from multiple Oracle threads, this IMessageEmitter
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
38 * implementation serializes the callbacks.
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
39 *
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
40 * The internal mutex used in Oracle messaging can also be used to
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
41 * protect the application data. Thus, this class can be used as a single
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
42 * application-wide mutex.
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
43 */
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
44 class LockingEmitter : public OrthancStone::IMessageEmitter
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 {
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
46 private:
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
47 boost::shared_mutex mutex_;
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
48 OrthancStone::IObservable oracleObservable_;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
50 public:
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
51 virtual void EmitMessage(boost::weak_ptr<OrthancStone::IObserver> observer,
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
52 const OrthancStone::IMessage& message) ORTHANC_OVERRIDE;
1097
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
53
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
54
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
55 class ReaderLock : public boost::noncopyable
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
56 {
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
57 private:
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
58 LockingEmitter& that_;
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
59 boost::shared_lock<boost::shared_mutex> lock_;
1097
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
60
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
61 public:
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
62 ReaderLock(LockingEmitter& that) :
1097
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
63 that_(that),
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
64 lock_(that.mutex_)
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
65 {
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
66 }
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
67 };
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
70 class WriterLock : public boost::noncopyable
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
71 {
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
72 private:
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
73 LockingEmitter& that_;
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
74 boost::unique_lock<boost::shared_mutex> lock_;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
76 public:
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
77 WriterLock(LockingEmitter& that) :
1097
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
78 that_(that),
4383382db01d deprecating LockingEmitter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1083
diff changeset
79 lock_(that.mutex_)
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
80 {
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
81 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
83 OrthancStone::IObservable& GetOracleObservable()
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
84 {
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
85 return that_.oracleObservable_;
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
86 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 };
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1098
diff changeset
88 };
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 }