Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Oracle/ThreadedOracle.h @ 1779:9ab251c03eda
unit test VolumeRendering.TextureCorners
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 May 2021 10:01:20 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
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 | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1604
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
748 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
748 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
748 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
1509
b7210c688ca7
linking SDL samples against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
25 #include <OrthancFramework.h> // To have the macros properly defined |
1604 | 26 #include <Compatibility.h> // ORTHANC_OVERRIDE |
1509
b7210c688ca7
linking SDL samples against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
27 |
748 | 28 #if !defined(ORTHANC_ENABLE_THREADS) |
29 # error The macro ORTHANC_ENABLE_THREADS must be defined | |
30 #endif | |
31 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
32 #if !defined(ORTHANC_ENABLE_DCMTK) |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
33 # 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
|
34 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
35 |
748 | 36 #if ORTHANC_ENABLE_THREADS != 1 |
37 # error This file can only compiled for native targets | |
38 #endif | |
39 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
40 #if ORTHANC_ENABLE_DCMTK == 1 |
1150 | 41 # include "../Toolbox/ParsedDicomCache.h" |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
42 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
43 |
748 | 44 #include "IOracle.h" |
1077 | 45 #include "GenericOracleRunner.h" |
1098
17660df24c36
simplification of IOracleRunner
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
46 #include "../Messages/IMessageEmitter.h" |
748 | 47 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
48 #include <MultiThreading/SharedMessageQueue.h> |
748 | 49 |
50 | |
51 namespace OrthancStone | |
52 { | |
53 class ThreadedOracle : public IOracle | |
54 { | |
55 private: | |
56 enum State | |
57 { | |
58 State_Setup, | |
59 State_Running, | |
60 State_Stopped | |
61 }; | |
62 | |
63 class Item; | |
64 class SleepingCommands; | |
65 | |
66 IMessageEmitter& emitter_; | |
67 Orthanc::WebServiceParameters orthanc_; | |
1109
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
68 std::string rootDirectory_; |
748 | 69 Orthanc::SharedMessageQueue queue_; |
70 State state_; | |
71 boost::mutex mutex_; | |
72 std::vector<boost::thread*> workers_; | |
73 boost::shared_ptr<SleepingCommands> sleepingCommands_; | |
74 boost::thread sleepingWorker_; | |
75 unsigned int sleepingTimeResolution_; | |
76 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
77 #if ORTHANC_ENABLE_DCMTK == 1 |
1150 | 78 boost::shared_ptr<ParsedDicomCache> dicomCache_; |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
79 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
80 |
748 | 81 void Step(); |
82 | |
83 static void Worker(ThreadedOracle* that); | |
84 | |
85 static void SleepingWorker(ThreadedOracle* that); | |
86 | |
87 void StopInternal(); | |
88 | |
89 public: | |
1571 | 90 explicit ThreadedOracle(IMessageEmitter& emitter); |
748 | 91 |
765 | 92 virtual ~ThreadedOracle(); |
748 | 93 |
94 void SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc); | |
95 | |
1109
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
96 void SetRootDirectory(const std::string& rootDirectory); |
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
97 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
748
diff
changeset
|
98 void SetThreadsCount(unsigned int count); |
748 | 99 |
100 void SetSleepingTimeResolution(unsigned int milliseconds); | |
101 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
102 void SetDicomCacheSize(size_t size); |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
103 |
825 | 104 void Start(); |
748 | 105 |
825 | 106 void Stop() |
748 | 107 { |
108 StopInternal(); | |
109 } | |
110 | |
1098
17660df24c36
simplification of IOracleRunner
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
111 virtual bool Schedule(boost::shared_ptr<IObserver> receiver, |
1077 | 112 IOracleCommand* command) ORTHANC_OVERRIDE; |
748 | 113 }; |
114 } |