# HG changeset patch # User Sebastien Jodogne # Date 1786700540 -7200 # Node ID fc06d1b317c33d09688e5f74a51f738812f9e635 # Parent cf85d06bda8a017e880c7c64928018770e7a0d45 cont ORTHANC_ENABLE_THREADS diff -r cf85d06bda8a -r fc06d1b317c3 OrthancFramework/Sources/Cache/MemoryObjectCache.cpp --- 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) diff -r cf85d06bda8a -r fc06d1b317c3 OrthancFramework/Sources/DicomParsing/ParsedDicomCache.cpp --- 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) diff -r cf85d06bda8a -r fc06d1b317c3 OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h --- 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 cache_; std::unique_ptr 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 accessor_;