comparison OrthancFramework/Sources/DicomParsing/ParsedDicomCache.cpp @ 4458:e4dae17035b9

fix ParsedDicomCache for emscripten
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Jan 2021 12:43:44 +0100
parents 789676a8c96a
children fa2311f94d9f
comparison
equal deleted inserted replaced
4457:789676a8c96a 4458:e4dae17035b9
69 } 69 }
70 70
71 71
72 size_t ParsedDicomCache::GetNumberOfItems() 72 size_t ParsedDicomCache::GetNumberOfItems()
73 { 73 {
74 boost::mutex::scoped_lock lock(mutex_); 74 #if !defined(__EMSCRIPTEN__)
75 boost::mutex::scoped_lock lock(mutex_);
76 #endif
75 77
76 if (cache_.get() == NULL) 78 if (cache_.get() == NULL)
77 { 79 {
78 return (largeDicom_.get() == NULL ? 0 : 1); 80 return (largeDicom_.get() == NULL ? 0 : 1);
79 } 81 }
86 } 88 }
87 89
88 90
89 size_t ParsedDicomCache::GetCurrentSize() 91 size_t ParsedDicomCache::GetCurrentSize()
90 { 92 {
91 boost::mutex::scoped_lock lock(mutex_); 93 #if !defined(__EMSCRIPTEN__)
94 boost::mutex::scoped_lock lock(mutex_);
95 #endif
92 96
93 if (cache_.get() == NULL) 97 if (cache_.get() == NULL)
94 { 98 {
95 return largeSize_; 99 return largeSize_;
96 } 100 }
103 } 107 }
104 108
105 109
106 void ParsedDicomCache::Invalidate(const std::string& id) 110 void ParsedDicomCache::Invalidate(const std::string& id)
107 { 111 {
108 boost::mutex::scoped_lock lock(mutex_); 112 #if !defined(__EMSCRIPTEN__)
113 boost::mutex::scoped_lock lock(mutex_);
114 #endif
109 115
110 if (cache_.get() != NULL) 116 if (cache_.get() != NULL)
111 { 117 {
112 cache_->Invalidate(id); 118 cache_->Invalidate(id);
113 } 119 }
122 128
123 void ParsedDicomCache::Acquire(const std::string& id, 129 void ParsedDicomCache::Acquire(const std::string& id,
124 ParsedDicomFile* dicom, // Takes ownership 130 ParsedDicomFile* dicom, // Takes ownership
125 size_t fileSize) 131 size_t fileSize)
126 { 132 {
127 boost::mutex::scoped_lock lock(mutex_); 133 #if !defined(__EMSCRIPTEN__)
134 boost::mutex::scoped_lock lock(mutex_);
135 #endif
128 136
129 if (fileSize >= cacheSize_) 137 if (fileSize >= cacheSize_)
130 { 138 {
131 cache_.reset(NULL); 139 cache_.reset(NULL);
132 largeDicom_.reset(dicom); 140 largeDicom_.reset(dicom);
149 } 157 }
150 158
151 159
152 ParsedDicomCache::Accessor::Accessor(ParsedDicomCache& that, 160 ParsedDicomCache::Accessor::Accessor(ParsedDicomCache& that,
153 const std::string& id) : 161 const std::string& id) :
162 #if !defined(__EMSCRIPTEN__)
154 lock_(that.mutex_), 163 lock_(that.mutex_),
164 #endif
155 id_(id), 165 id_(id),
156 file_(NULL), 166 file_(NULL),
157 fileSize_(0) 167 fileSize_(0)
158 { 168 {
159 if (that.largeDicom_.get() != NULL && 169 if (that.largeDicom_.get() != NULL &&