Mercurial > hg > orthanc
changeset 7117:fc06d1b317c3
cont ORTHANC_ENABLE_THREADS
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Fri, 14 Aug 2026 11:42:20 +0200 |
| parents | cf85d06bda8a |
| children | 50503cd4e588 |
| files | OrthancFramework/Sources/Cache/MemoryObjectCache.cpp OrthancFramework/Sources/DicomParsing/ParsedDicomCache.cpp OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h |
| diffstat | 3 files changed, 18 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/Cache/MemoryObjectCache.cpp Fri Aug 14 11:37:29 2026 +0200 +++ b/OrthancFramework/Sources/Cache/MemoryObjectCache.cpp Fri Aug 14 11:42:20 2026 +0200 @@ -117,7 +117,7 @@ size_t MemoryObjectCache::GetNumberOfItems() { -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 boost::mutex::scoped_lock lock(cacheMutex_); #endif @@ -127,7 +127,7 @@ size_t MemoryObjectCache::GetCurrentSize() { -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 boost::mutex::scoped_lock lock(cacheMutex_); #endif @@ -137,7 +137,7 @@ size_t MemoryObjectCache::GetMaximumSize() { -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 boost::mutex::scoped_lock lock(cacheMutex_); #endif @@ -152,7 +152,7 @@ throw OrthancException(ErrorCode_ParameterOutOfRange); } -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 // Make sure no accessor is currently open (as its data may be // removed if recycling is needed) WriterLock contentLock(contentMutex_); @@ -177,7 +177,7 @@ } else { -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 // Make sure no accessor is currently open (as its data may be // removed if recycling is needed) WriterLock contentLock(contentMutex_); @@ -211,7 +211,7 @@ void MemoryObjectCache::Invalidate(const std::string& key) { -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 // Make sure no accessor is currently open (as it may correspond // to the key to remove) WriterLock contentLock(contentMutex_); @@ -240,7 +240,7 @@ bool unique) : item_(NULL) { -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 if (unique) { writerLock_ = WriterLock(cache.contentMutex_); @@ -260,7 +260,7 @@ cache.content_.MakeMostRecent(key); } -#if !defined(__EMSCRIPTEN__) +#if ORTHANC_ENABLE_THREADS == 1 cacheLock_.unlock(); if (item_ == NULL)
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomCache.cpp Fri Aug 14 11:37:29 2026 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomCache.cpp Fri Aug 14 11:42:20 2026 +0200 @@ -77,9 +77,7 @@ size_t ParsedDicomCache::GetNumberOfItems() { -#if !defined(__EMSCRIPTEN__) - boost::mutex::scoped_lock lock(mutex_); -#endif + Mutex::ScopedLock lock(mutex_); if (cache_.get() == NULL) { @@ -96,9 +94,7 @@ size_t ParsedDicomCache::GetCurrentSize() { -#if !defined(__EMSCRIPTEN__) - boost::mutex::scoped_lock lock(mutex_); -#endif + Mutex::ScopedLock lock(mutex_); if (cache_.get() == NULL) { @@ -115,9 +111,7 @@ void ParsedDicomCache::Invalidate(const std::string& id) { -#if !defined(__EMSCRIPTEN__) - boost::mutex::scoped_lock lock(mutex_); -#endif + Mutex::ScopedLock lock(mutex_); if (cache_.get() != NULL) { @@ -136,9 +130,7 @@ ParsedDicomFile* dicom, // Takes ownership size_t fileSize) { -#if !defined(__EMSCRIPTEN__) - boost::mutex::scoped_lock lock(mutex_); -#endif + Mutex::ScopedLock lock(mutex_); if (fileSize >= cacheSize_) { @@ -165,9 +157,7 @@ ParsedDicomCache::Accessor::Accessor(ParsedDicomCache& that, const std::string& id) : -#if !defined(__EMSCRIPTEN__) lock_(that.mutex_), -#endif id_(id), file_(NULL), fileSize_(0)
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h Fri Aug 14 11:37:29 2026 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h Fri Aug 14 11:42:20 2026 +0200 @@ -25,6 +25,7 @@ #pragma once #include "../Cache/MemoryObjectCache.h" +#include "../MultiThreading/Mutex.h" #include "ParsedDicomFile.h" namespace Orthanc @@ -34,10 +35,7 @@ private: class Item; -#if !defined(__EMSCRIPTEN__) - boost::mutex mutex_; -#endif - + Mutex mutex_; size_t cacheSize_; std::unique_ptr<MemoryObjectCache> cache_; std::unique_ptr<ParsedDicomFile> largeDicom_; @@ -60,13 +58,10 @@ class ORTHANC_PUBLIC Accessor : public boost::noncopyable { private: -#if !defined(__EMSCRIPTEN__) - boost::mutex::scoped_lock lock_; -#endif - - std::string id_; - ParsedDicomFile* file_; - size_t fileSize_; + Mutex::ScopedLock lock_; + std::string id_; + ParsedDicomFile* file_; + size_t fileSize_; std::unique_ptr<MemoryObjectCache::Accessor> accessor_;
