comparison Framework/Toolbox/ParsedDicomFileCache.cpp @ 1140:6333e6f7248e broker

fix cache
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Nov 2019 16:53:15 +0100
parents 42581a6182c8
children
comparison
equal deleted inserted replaced
1139:8d2f1b25593c 1140:6333e6f7248e
77 } 77 }
78 78
79 79
80 ParsedDicomFileCache::Reader::Reader(ParsedDicomFileCache& cache, 80 ParsedDicomFileCache::Reader::Reader(ParsedDicomFileCache& cache,
81 const std::string& path) : 81 const std::string& path) :
82 reader_(cache.cache_, path) 82 /**
83 * The "DcmFileFormat" object cannot be accessed from multiple
84 * threads, even if using only getters. An unique lock (mutex) is
85 * mandatory.
86 **/
87 accessor_(cache.cache_, path, true /* unique */)
83 { 88 {
84 if (reader_.IsValid()) 89 if (accessor_.IsValid())
85 { 90 {
86 /** 91 item_ = &dynamic_cast<Item&>(accessor_.GetValue());
87 * The "Orthanc::MemoryObjectCache" uses readers/writers. The
88 * "Reader" subclass of the cache locks as a reader. This means
89 * that multiple threads can still access the underlying
90 * "ParsedDicomFile" object, which is not supported by DCMTK. We
91 * thus protect the DCMTK object by a simple mutex.
92 **/
93
94 item_ = &dynamic_cast<Item&>(reader_.GetValue());
95 lock_.reset(new boost::mutex::scoped_lock(item_->GetMutex()));
96 } 92 }
97 else 93 else
98 { 94 {
99 item_ = NULL; 95 item_ = NULL;
100 } 96 }