comparison OrthancFramework/Sources/DicomParsing/ParsedDicomCache.cpp @ 4457:789676a8c96a

Refactoring and improvements to the cache of DICOM files in ServerContext
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 Jan 2021 19:05:04 +0100
parents 3e4f7b7840f0
children e4dae17035b9
comparison
equal deleted inserted replaced
4456:3e4f7b7840f0 4457:789676a8c96a
67 throw OrthancException(ErrorCode_ParameterOutOfRange); 67 throw OrthancException(ErrorCode_ParameterOutOfRange);
68 } 68 }
69 } 69 }
70 70
71 71
72 size_t ParsedDicomCache::GetCurrentSize() // For unit tests only 72 size_t ParsedDicomCache::GetNumberOfItems()
73 { 73 {
74 boost::mutex::scoped_lock lock(mutex_); 74 boost::mutex::scoped_lock lock(mutex_);
75 75
76 if (cache_.get() == NULL) 76 if (cache_.get() == NULL)
77 { 77 {
78 return (largeDicom_.get() == NULL ? 0 : 1);
79 }
80 else
81 {
82 assert(largeDicom_.get() == NULL);
83 assert(largeSize_ == 0);
84 return cache_->GetNumberOfItems();
85 }
86 }
87
88
89 size_t ParsedDicomCache::GetCurrentSize()
90 {
91 boost::mutex::scoped_lock lock(mutex_);
92
93 if (cache_.get() == NULL)
94 {
78 return largeSize_; 95 return largeSize_;
79 } 96 }
80 else 97 else
81 { 98 {
99 assert(largeDicom_.get() == NULL);
82 assert(largeSize_ == 0); 100 assert(largeSize_ == 0);
83 return cache_->GetCurrentSize(); 101 return cache_->GetCurrentSize();
84 } 102 }
85 } 103 }
86 104