Mercurial > hg > orthanc
changeset 6967:edd68dfbdd98 streaming
removed IExecutorService::GetCountThreads() to stick with Java SDK
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Mon, 29 Jun 2026 16:03:00 +0200 |
| parents | d28c3fb90bd6 |
| children | 2c0edc2660f0 |
| files | OrthancFramework/Sources/DataSource/DataSourceReader.cpp OrthancFramework/Sources/DataSource/DataSourceReader.h OrthancFramework/Sources/MultiThreading/IExecutorService.h OrthancFramework/Sources/MultiThreading/ThreadPool.cpp OrthancFramework/Sources/MultiThreading/ThreadPool.h OrthancFramework/UnitTestsSources/JobsTests.cpp OrthancServer/Sources/ServerContext.cpp |
| diffstat | 7 files changed, 30 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DataSource/DataSourceReader.cpp Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceReader.cpp Mon Jun 29 16:03:00 2026 +0200 @@ -323,10 +323,6 @@ return maximumMemory; } - unsigned int DataSourceReader::GetThreadsCount() const - { - return executor_->GetCountThreads(); - } boost::shared_ptr<DataSourceAnswer> DataSourceReader::Submit(DataSourceRequest* request /* takes ownership */) {
--- a/OrthancFramework/Sources/DataSource/DataSourceReader.h Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceReader.h Mon Jun 29 16:03:00 2026 +0200 @@ -98,6 +98,11 @@ ~DataSourceReader(); + const boost::shared_ptr<IExecutorService>& GetExecutorService() const + { + return executor_; + } + void SetMetricsConfiguration(const MetricsConfiguration& configuration); void CreateCache(size_t capacity); @@ -110,7 +115,6 @@ uint64_t GetCapacity() const; - unsigned int GetThreadsCount() const; /** * Request the data source to load a set of items. The values will * be read in parallel by a thread pool (cf. "executor_") and will
--- a/OrthancFramework/Sources/MultiThreading/IExecutorService.h Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancFramework/Sources/MultiThreading/IExecutorService.h Mon Jun 29 16:03:00 2026 +0200 @@ -43,7 +43,5 @@ virtual void Submit(IRunnable* runnable /* takes ownership */) = 0; virtual void Stop() = 0; - - virtual unsigned int GetCountThreads() = 0; }; }
--- a/OrthancFramework/Sources/MultiThreading/ThreadPool.cpp Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancFramework/Sources/MultiThreading/ThreadPool.cpp Mon Jun 29 16:03:00 2026 +0200 @@ -304,7 +304,7 @@ } - void ThreadPool::SetCountThreads(unsigned int count) + void ThreadPool::SetThreadsCount(unsigned int count) { if (count < 1) { @@ -326,7 +326,7 @@ } - unsigned int ThreadPool::GetCountThreads() + unsigned int ThreadPool::GetThreadsCount() { boost::mutex::scoped_lock lock(mutex_); return countThreads_;
--- a/OrthancFramework/Sources/MultiThreading/ThreadPool.h Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancFramework/Sources/MultiThreading/ThreadPool.h Mon Jun 29 16:03:00 2026 +0200 @@ -68,9 +68,9 @@ void SetLoggingThreadName(const std::string& name); - void SetCountThreads(unsigned int count); + void SetThreadsCount(unsigned int count); - virtual unsigned int GetCountThreads() ORTHANC_OVERRIDE; + unsigned int GetThreadsCount(); void SetDequeueTimeout(unsigned int milliseconds);
--- a/OrthancFramework/UnitTestsSources/JobsTests.cpp Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp Mon Jun 29 16:03:00 2026 +0200 @@ -1843,10 +1843,10 @@ TEST(ThreadPool, Basic) { ThreadPool pool; - ASSERT_THROW(pool.SetCountThreads(0), OrthancException); + ASSERT_THROW(pool.SetThreadsCount(0), OrthancException); ASSERT_THROW(pool.SetDequeueTimeout(0), OrthancException); pool.SetDequeueTimeout(1); // Ensure fast shutdown in unit tests - ASSERT_EQ(1u, pool.GetCountThreads()); + ASSERT_EQ(1u, pool.GetThreadsCount()); ASSERT_EQ(1u, pool.GetDequeueTimeout()); pool.Start();
--- a/OrthancServer/Sources/ServerContext.cpp Mon Jun 29 15:47:19 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Mon Jun 29 16:03:00 2026 +0200 @@ -747,7 +747,7 @@ // For streaming { boost::shared_ptr<ThreadPool> pool(new ThreadPool); - pool->SetCountThreads(storageLoaderThreads); + pool->SetThreadsCount(storageLoaderThreads); pool->SetLoggingThreadName("STORAGE-SRC"); pool->SetDequeueTimeout(100); pool->SetMetricsConfiguration(*metricsRegistry_, METRICS_STORAGE_THREAD_POOL_AVAILABLE_THREADS); @@ -775,7 +775,7 @@ { boost::shared_ptr<ThreadPool> pool(new ThreadPool); - pool->SetCountThreads(dicomParserThreads); + pool->SetThreadsCount(dicomParserThreads); pool->SetLoggingThreadName("DICOM-SRC"); pool->SetDequeueTimeout(100); pool->SetMetricsConfiguration(*metricsRegistry_, METRICS_DICOM_PARSER_THREAD_POOL_AVAILABLE_THREADS); @@ -800,7 +800,7 @@ if (transcoder_.get() != NULL) { boost::shared_ptr<ThreadPool> pool(new ThreadPool); - pool->SetCountThreads(transcoderThreads); + pool->SetThreadsCount(transcoderThreads); pool->SetLoggingThreadName("TRANSCODER"); pool->SetDequeueTimeout(100); pool->SetMetricsConfiguration(*metricsRegistry_, METRICS_TRANSCODER_THREAD_POOL_AVAILABLE_THREADS); @@ -831,7 +831,7 @@ // } std::unique_ptr<ThreadPool> pool(new ThreadPool); - pool->SetCountThreads(sequentialReaderThreads); // TODO-Streaming - Check - clarify the difference between SequentialLoader and DataSourceReader + pool->SetThreadsCount(sequentialReaderThreads); // TODO-Streaming - Check - clarify the difference between SequentialLoader and DataSourceReader pool->SetLoggingThreadName("SEQ-READER"); pool->SetDequeueTimeout(100); pool->SetMetricsConfiguration(*metricsRegistry_, METRICS_SEQ_READER_THREAD_POOL_AVAILABLE_THREADS); @@ -2422,12 +2422,24 @@ { storageMemoryCapacityMb = storageAreaReader_->GetCapacity(); storageMemoryCacheMb = storageAreaReader_->GetCacheCapacity(); - storageReaderThreadsCount = storageAreaReader_->GetThreadsCount(); transcoderMemoryCapacityMb = transcoderReader_->GetCapacity(); transcoderMemoryCacheMb = transcoderReader_->GetCacheCapacity(); - transcoderReaderThreadsCount = transcoderReader_->GetThreadsCount(); dicomParserMemoryCapacityMb = dicomReader_->GetCapacity(); dicomParserMemoryCacheMb = dicomReader_->GetCacheCapacity(); - dicomParserThreadsCount = dicomReader_->GetThreadsCount(); + + { + boost::shared_ptr<IExecutorService> service = storageAreaReader_->GetExecutorService(); + storageReaderThreadsCount = dynamic_cast<ThreadPool&>(*service).GetThreadsCount(); + } + + { + boost::shared_ptr<IExecutorService> service = transcoderReader_->GetExecutorService(); + transcoderReaderThreadsCount = dynamic_cast<ThreadPool&>(*service).GetThreadsCount(); + } + + { + boost::shared_ptr<IExecutorService> service = dicomReader_->GetExecutorService(); + dicomParserThreadsCount = dynamic_cast<ThreadPool&>(*service).GetThreadsCount(); + } } }
