Mercurial > hg > orthanc-stone
diff Framework/Loaders/GenericLoadersContext.cpp @ 1247:af35ec39ebec broker
refactoring ILoadersContext
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jan 2020 13:12:43 +0100 |
parents | b9b5d4378874 |
children | 0ca50d275b9a |
line wrap: on
line diff
--- a/Framework/Loaders/GenericLoadersContext.cpp Tue Jan 07 12:56:40 2020 +0100 +++ b/Framework/Loaders/GenericLoadersContext.cpp Tue Jan 07 13:12:43 2020 +0100 @@ -34,6 +34,10 @@ that_(that), lock_(that.mutex_) { + if (!that_.scheduler_) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } } virtual ILoadersContext& GetContext() const ORTHANC_OVERRIDE @@ -67,6 +71,13 @@ { that_.scheduler_->CancelAllRequests(); } + + virtual void GetStatistics(uint64_t& scheduledCommands, + uint64_t& processedCommands) + { + scheduledCommands = that_.scheduler_->GetTotalScheduled(); + processedCommands = that_.scheduler_->GetTotalProcessed(); + } }; @@ -87,6 +98,11 @@ oracle_.reset(new ThreadedOracle(*this)); scheduler_ = OracleScheduler::Create(*oracle_, oracleObservable_, *this, maxHighPriority, maxStandardPriority, maxLowPriority); + + if (!scheduler_) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } } @@ -160,26 +176,8 @@ } } - ILoadersContext::ILock* GenericLoadersContext::Lock() { return new Locker(*this); } - - - void GenericLoadersContext::GetStatistics(uint64_t& scheduledCommands, - uint64_t& processedCommands) - { - boost::recursive_mutex::scoped_lock lock(mutex_); - - if (scheduler_) - { - scheduledCommands = scheduler_->GetTotalScheduled(); - processedCommands = scheduler_->GetTotalProcessed(); - } - else - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); - } - } }