Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Oracle/ThreadedOracle.h @ 2123:538c7b7c6e46 deep-learning
integration mainline->deep-learning
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 22 Mar 2024 16:11:42 +0100 |
parents | c23eef785569 |
children | 16c01cc201e7 |
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 | |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
748 | 7 * |
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
748 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * 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
|
15 * 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
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
748 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
1509
b7210c688ca7
linking SDL samples against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
26 #include <OrthancFramework.h> // To have the macros properly defined |
1604 | 27 #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
|
28 |
748 | 29 #if !defined(ORTHANC_ENABLE_THREADS) |
30 # error The macro ORTHANC_ENABLE_THREADS must be defined | |
31 #endif | |
32 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
33 #if !defined(ORTHANC_ENABLE_DCMTK) |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
34 # 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
|
35 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
36 |
748 | 37 #if ORTHANC_ENABLE_THREADS != 1 |
38 # error This file can only compiled for native targets | |
39 #endif | |
40 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
41 #if ORTHANC_ENABLE_DCMTK == 1 |
1150 | 42 # include "../Toolbox/ParsedDicomCache.h" |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
43 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
44 |
748 | 45 #include "IOracle.h" |
1077 | 46 #include "GenericOracleRunner.h" |
1098
17660df24c36
simplification of IOracleRunner
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
47 #include "../Messages/IMessageEmitter.h" |
748 | 48 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
49 #include <MultiThreading/SharedMessageQueue.h> |
748 | 50 |
51 | |
52 namespace OrthancStone | |
53 { | |
54 class ThreadedOracle : public IOracle | |
55 { | |
56 private: | |
57 enum State | |
58 { | |
59 State_Setup, | |
60 State_Running, | |
61 State_Stopped | |
62 }; | |
63 | |
64 class Item; | |
65 class SleepingCommands; | |
66 | |
67 IMessageEmitter& emitter_; | |
68 Orthanc::WebServiceParameters orthanc_; | |
1109
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
69 std::string rootDirectory_; |
748 | 70 Orthanc::SharedMessageQueue queue_; |
71 State state_; | |
72 boost::mutex mutex_; | |
73 std::vector<boost::thread*> workers_; | |
74 boost::shared_ptr<SleepingCommands> sleepingCommands_; | |
75 boost::thread sleepingWorker_; | |
76 unsigned int sleepingTimeResolution_; | |
77 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
78 #if ORTHANC_ENABLE_DCMTK == 1 |
1150 | 79 boost::shared_ptr<ParsedDicomCache> dicomCache_; |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
80 #endif |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
81 |
748 | 82 void Step(); |
83 | |
84 static void Worker(ThreadedOracle* that); | |
85 | |
86 static void SleepingWorker(ThreadedOracle* that); | |
87 | |
88 void StopInternal(); | |
89 | |
90 public: | |
1571 | 91 explicit ThreadedOracle(IMessageEmitter& emitter); |
748 | 92 |
765 | 93 virtual ~ThreadedOracle(); |
748 | 94 |
95 void SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc); | |
96 | |
1109
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
97 void SetRootDirectory(const std::string& rootDirectory); |
79b1b541fe15
ThreadedOracle::SetRootDirectory()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
98 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
748
diff
changeset
|
99 void SetThreadsCount(unsigned int count); |
748 | 100 |
101 void SetSleepingTimeResolution(unsigned int milliseconds); | |
102 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
103 void SetDicomCacheSize(size_t size); |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1109
diff
changeset
|
104 |
825 | 105 void Start(); |
748 | 106 |
825 | 107 void Stop() |
748 | 108 { |
109 StopInternal(); | |
110 } | |
111 | |
1098
17660df24c36
simplification of IOracleRunner
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
112 virtual bool Schedule(boost::shared_ptr<IObserver> receiver, |
1077 | 113 IOracleCommand* command) ORTHANC_OVERRIDE; |
748 | 114 }; |
115 } |