Mercurial > hg > orthanc
annotate OrthancFramework/Sources/JobsEngine/JobsEngine.h @ 4844:55e8fb8e8028
tagging a pre-release of the Orthanc framework for WSI 1.1
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Dec 2021 14:01:17 +0100 |
parents | 7053502fbf97 |
children | 43e613a7756b |
rev | line source |
---|---|
2569 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
4831
7053502fbf97
added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2569 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * the License, or (at your option) any later version. |
2569 | 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 | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
16 * Lesser General Public License for more details. |
2569 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
2569 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "JobsRegistry.h" | |
27 | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
28 #include "../Compatibility.h" |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
29 |
2569 | 30 #include <boost/thread.hpp> |
31 | |
32 namespace Orthanc | |
33 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
34 class ORTHANC_PUBLIC JobsEngine : public boost::noncopyable |
2569 | 35 { |
36 private: | |
37 enum State | |
38 { | |
39 State_Setup, | |
40 State_Running, | |
41 State_Stopping, | |
42 State_Done | |
43 }; | |
44 | |
2591
441f23af9d89
fix for older releases of boost::thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
45 boost::mutex stateMutex_; |
441f23af9d89
fix for older releases of boost::thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
46 State state_; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
47 std::unique_ptr<JobsRegistry> registry_; |
2591
441f23af9d89
fix for older releases of boost::thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
48 boost::thread retryHandler_; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2591
diff
changeset
|
49 unsigned int threadSleep_; |
2591
441f23af9d89
fix for older releases of boost::thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
50 std::vector<boost::thread*> workers_; |
2569 | 51 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
52 bool IsRunning(); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
53 |
2569 | 54 bool ExecuteStep(JobsRegistry::RunningJob& running, |
55 size_t workerIndex); | |
56 | |
57 static void RetryHandler(JobsEngine* engine); | |
58 | |
59 static void Worker(JobsEngine* engine, | |
60 size_t workerIndex); | |
61 | |
62 public: | |
4202
2007ab69ac16
moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
63 explicit JobsEngine(size_t maxCompletedJobs); |
2569 | 64 |
65 ~JobsEngine(); | |
66 | |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
67 JobsRegistry& GetRegistry(); |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
68 |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
69 void LoadRegistryFromJson(IJobUnserializer& unserializer, |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
70 const Json::Value& serialized); |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
71 |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
72 void LoadRegistryFromString(IJobUnserializer& unserializer, |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
73 const std::string& serialized); |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
74 |
2569 | 75 void SetWorkersCount(size_t count); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2591
diff
changeset
|
76 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2591
diff
changeset
|
77 void SetThreadSleep(unsigned int sleep); |
2569 | 78 |
79 void Start(); | |
80 | |
81 void Stop(); | |
82 }; | |
83 } |