Mercurial > hg > orthanc-stone
annotate Framework/Oracle/ThreadedOracle.h @ 925:4639d0bf6390
Added support for Grayscale16 in the multiframe loader (Victor)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 22 Jul 2019 16:00:03 +0200 |
parents | 3a984741686f |
children | 81b29bc7c3d4 2d8ab34c8c91 |
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 | |
28 #if ORTHANC_ENABLE_THREADS != 1 | |
29 # error This file can only compiled for native targets | |
30 #endif | |
31 | |
32 #include "../Messages/IMessageEmitter.h" | |
33 #include "IOracle.h" | |
34 | |
35 #include <Core/WebServiceParameters.h> | |
36 #include <Core/MultiThreading/SharedMessageQueue.h> | |
37 | |
38 | |
39 namespace OrthancStone | |
40 { | |
41 class ThreadedOracle : public IOracle | |
42 { | |
43 private: | |
44 enum State | |
45 { | |
46 State_Setup, | |
47 State_Running, | |
48 State_Stopped | |
49 }; | |
50 | |
51 class Item; | |
52 class SleepingCommands; | |
53 | |
54 IMessageEmitter& emitter_; | |
55 Orthanc::WebServiceParameters orthanc_; | |
56 Orthanc::SharedMessageQueue queue_; | |
57 State state_; | |
58 boost::mutex mutex_; | |
59 std::vector<boost::thread*> workers_; | |
60 boost::shared_ptr<SleepingCommands> sleepingCommands_; | |
61 boost::thread sleepingWorker_; | |
62 unsigned int sleepingTimeResolution_; | |
63 | |
64 void Step(); | |
65 | |
66 static void Worker(ThreadedOracle* that); | |
67 | |
68 static void SleepingWorker(ThreadedOracle* that); | |
69 | |
70 void StopInternal(); | |
71 | |
72 public: | |
73 ThreadedOracle(IMessageEmitter& emitter); | |
74 | |
765 | 75 virtual ~ThreadedOracle(); |
748 | 76 |
828 | 77 // The reference is not stored. |
748 | 78 void SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc); |
79 | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
748
diff
changeset
|
80 void SetThreadsCount(unsigned int count); |
748 | 81 |
82 void SetSleepingTimeResolution(unsigned int milliseconds); | |
83 | |
825 | 84 void Start(); |
748 | 85 |
825 | 86 void Stop() |
748 | 87 { |
88 StopInternal(); | |
89 } | |
90 | |
91 virtual void Schedule(const IObserver& receiver, | |
92 IOracleCommand* command); | |
93 }; | |
94 } |