Mercurial > hg > orthanc-stone
annotate Framework/Oracle/ThreadedOracle.h @ 1145:4f99c7905f8d broker
mingw qt
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 12 Nov 2019 18:28:46 +0100 |
parents | a8bf81756839 |
children | 7aad0984d38a |
rev | line source |
---|---|
748 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #if !defined(ORTHANC_ENABLE_THREADS) | |
25 # error The macro ORTHANC_ENABLE_THREADS must be defined | |
26 #endif | |
27 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
28 #if !defined(ORTHANC_ENABLE_DCMTK) |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
29 # error The macro ORTHANC_ENABLE_DCMTK must be defined |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
30 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
31 |
748 | 32 #if ORTHANC_ENABLE_THREADS != 1 |
33 # error This file can only compiled for native targets | |
34 #endif | |
35 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
36 #if ORTHANC_ENABLE_DCMTK == 1 |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
37 # include "../Toolbox/ParsedDicomFileCache.h" |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
38 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
39 |
748 | 40 #include "IOracle.h" |
1077 | 41 #include "GenericOracleRunner.h" |
1098
17660df24c36
simplification of IOracleRunner
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
42 #include "../Messages/IMessageEmitter.h" |
748 | 43 |
44 #include <Core/MultiThreading/SharedMessageQueue.h> | |
45 | |
46 | |
47 namespace OrthancStone | |
48 { | |
49 class ThreadedOracle : public IOracle | |
50 { | |
51 private: | |
52 enum State | |
53 { | |
54 State_Setup, | |
55 State_Running, | |
56 State_Stopped | |
57 }; | |
58 | |
59 class Item; | |
60 class SleepingCommands; | |
61 | |
62 IMessageEmitter& emitter_; | |
63 Orthanc::WebServiceParameters orthanc_; | |
1109
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
64 std::string rootDirectory_; |
748 | 65 Orthanc::SharedMessageQueue queue_; |
66 State state_; | |
67 boost::mutex mutex_; | |
68 std::vector<boost::thread*> workers_; | |
69 boost::shared_ptr<SleepingCommands> sleepingCommands_; | |
70 boost::thread sleepingWorker_; | |
71 unsigned int sleepingTimeResolution_; | |
72 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
73 #if ORTHANC_ENABLE_DCMTK == 1 |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
74 boost::shared_ptr<ParsedDicomFileCache> dicomCache_; |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
75 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
76 |
748 | 77 void Step(); |
78 | |
79 static void Worker(ThreadedOracle* that); | |
80 | |
81 static void SleepingWorker(ThreadedOracle* that); | |
82 | |
83 void StopInternal(); | |
84 | |
85 public: | |
86 ThreadedOracle(IMessageEmitter& emitter); | |
87 | |
765 | 88 virtual ~ThreadedOracle(); |
748 | 89 |
90 void SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc); | |
91 | |
1109
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
92 void SetRootDirectory(const std::string& rootDirectory); |
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
93 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
748
diff
changeset
|
94 void SetThreadsCount(unsigned int count); |
748 | 95 |
96 void SetSleepingTimeResolution(unsigned int milliseconds); | |
97 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
98 void SetDicomCacheSize(size_t size); |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
99 |
825 | 100 void Start(); |
748 | 101 |
825 | 102 void Stop() |
748 | 103 { |
104 StopInternal(); | |
105 } | |
106 | |
1098
17660df24c36
simplification of IOracleRunner
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
107 virtual bool Schedule(boost::shared_ptr<IObserver> receiver, |
1077 | 108 IOracleCommand* command) ORTHANC_OVERRIDE; |
748 | 109 }; |
110 } |