Mercurial > hg > orthanc
diff OrthancServer/ServerContext.cpp @ 2673:8e0bc055d18c jobs
JobsRegistry::IObserver
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 11 Jun 2018 16:29:33 +0200 |
parents | 3efc44fac209 |
children | 3fc310ceb6d4 |
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp Mon Jun 11 15:57:25 2018 +0200 +++ b/OrthancServer/ServerContext.cpp Mon Jun 11 16:29:33 2018 +0200 @@ -121,15 +121,41 @@ { boost::this_thread::sleep(boost::posix_time::milliseconds(sleepDelay)); - if (boost::posix_time::microsec_clock::universal_time() >= next) + if (that->haveJobsChanged_ || + boost::posix_time::microsec_clock::universal_time() >= next) { - that->SaveJobsEngine(); + that->haveJobsChanged_ = false; + that->SaveJobsEngine(); next = boost::posix_time::microsec_clock::universal_time() + PERIODICITY; } } } + + + void ServerContext::SignalJobSubmitted(const std::string& jobId) + { + haveJobsChanged_ = true; + + // TODO: Call Lua + } + + + void ServerContext::SignalJobSuccess(const std::string& jobId) + { + haveJobsChanged_ = true; + + // TODO: Call Lua + } + void ServerContext::SignalJobFailure(const std::string& jobId) + { + haveJobsChanged_ = true; + + // TODO: Call Lua + } + + void ServerContext::SetupJobsEngine(bool unitTesting, bool loadJobsFromDatabase) { @@ -166,6 +192,7 @@ //jobsEngine_.GetRegistry().SetMaxCompleted // TODO + jobsEngine_.GetRegistry().SetObserver(*this); jobsEngine_.Start(); } @@ -206,6 +233,7 @@ plugins_(NULL), #endif done_(false), + haveJobsChanged_(false), queryRetrieveArchive_(Configuration::GetGlobalUnsignedIntegerParameter("QueryRetrieveSize", 10)), defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC")) { @@ -250,6 +278,7 @@ saveJobsThread_.join(); } + jobsEngine_.GetRegistry().ResetObserver(); SaveJobsEngine(); // Do not change the order below!