Mercurial > hg > orthanc
comparison OrthancServer/Scheduler/ServerScheduler.h @ 995:8c67382f44a7 lua-scripting
limit number of jobs in the scheduler
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 03 Jul 2014 15:58:53 +0200 |
parents | f0ac3a53ccf2 |
children | db18c071fbd7 |
comparison
equal
deleted
inserted
replaced
994:b3d4f8a30324 | 995:8c67382f44a7 |
---|---|
32 | 32 |
33 #pragma once | 33 #pragma once |
34 | 34 |
35 #include "ServerJob.h" | 35 #include "ServerJob.h" |
36 | 36 |
37 #include "../../Core/MultiThreading/Semaphore.h" | |
38 | |
37 namespace Orthanc | 39 namespace Orthanc |
38 { | 40 { |
39 class ServerScheduler : public ServerFilterInstance::IListener | 41 class ServerScheduler : public ServerFilterInstance::IListener |
40 { | 42 { |
41 private: | 43 private: |
58 | 60 |
59 typedef IServerFilter::ListOfStrings ListOfStrings; | 61 typedef IServerFilter::ListOfStrings ListOfStrings; |
60 typedef std::map<std::string, JobInfo> Jobs; | 62 typedef std::map<std::string, JobInfo> Jobs; |
61 | 63 |
62 boost::mutex mutex_; | 64 boost::mutex mutex_; |
63 boost::condition_variable jobFinished_; | 65 boost::condition_variable watchedJobFinished_; |
64 Jobs jobs_; | 66 Jobs jobs_; |
65 SharedMessageQueue queue_; | 67 SharedMessageQueue queue_; |
66 bool finish_; | 68 bool finish_; |
67 boost::thread worker_; | 69 boost::thread worker_; |
68 std::map<std::string, JobStatus> watchedJobStatus_; | 70 std::map<std::string, JobStatus> watchedJobStatus_; |
71 Semaphore availableJob_; | |
69 | 72 |
70 JobInfo& GetJobInfo(const std::string& jobId); | 73 JobInfo& GetJobInfo(const std::string& jobId); |
71 | 74 |
72 virtual void SignalSuccess(const std::string& jobId); | 75 virtual void SignalSuccess(const std::string& jobId); |
73 | 76 |
77 | 80 |
78 void SubmitInternal(ServerJob& job, | 81 void SubmitInternal(ServerJob& job, |
79 bool watched); | 82 bool watched); |
80 | 83 |
81 public: | 84 public: |
82 ServerScheduler(); | 85 ServerScheduler(unsigned int maxjobs); |
83 | 86 |
84 ~ServerScheduler(); | 87 ~ServerScheduler(); |
85 | 88 |
86 void Submit(ServerJob& job); | 89 void Submit(ServerJob& job); |
87 | 90 |