From 00444deae4fa7a30a0ac3f9223e8bd2a93273b1a Mon Sep 17 00:00:00 2001 From: Anton Piccardo-Selg <anton.piccardo-selg@tessella.com> Date: Thu, 18 Feb 2016 10:01:24 +0000 Subject: [PATCH] Refs #15288 Change mutex for BoxControllerNexusIO --- .../MantidDataObjects/BoxControllerNeXusIO.h | 6 ++--- .../DataObjects/src/BoxControllerNeXusIO.cpp | 10 ++++---- .../DataObjects/src/EventWorkspaceMRU.cpp | 24 +++++++++---------- Framework/DataObjects/src/PeakColumn.cpp | 2 -- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h b/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h index d67ee83a3c0..d9eedc4e68d 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h +++ b/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h @@ -4,7 +4,6 @@ #include "MantidAPI/IBoxControllerIO.h" #include "MantidAPI/BoxController.h" #include "MantidKernel/DiskBuffer.h" -#include <Poco/Mutex.h> #include <nexus/NeXusFile.hpp> namespace Mantid { @@ -102,9 +101,8 @@ private: /// the vector, which describes the event specific data size, namely how many /// column an event is composed into and this class reads/writres std::vector<int64_t> m_BlockSize; - /// lock Nexus file operations as Nexus is not thread safe // Poco::Mutex -- > - /// is recursive. - mutable Poco::FastMutex m_fileMutex; + /// lock Nexus file operations as Nexus is not thread safe + mutable Mantid::Kernel::Mutex m_fileMutex; // Mainly static information which may be split into different IO classes // selected through chein of responsibility. diff --git a/Framework/DataObjects/src/BoxControllerNeXusIO.cpp b/Framework/DataObjects/src/BoxControllerNeXusIO.cpp index 61a23013cee..6bb288a89aa 100644 --- a/Framework/DataObjects/src/BoxControllerNeXusIO.cpp +++ b/Framework/DataObjects/src/BoxControllerNeXusIO.cpp @@ -116,7 +116,7 @@ bool BoxControllerNeXusIO::openFile(const std::string &fileName, if (m_File) return false; - Poco::ScopedLock<Poco::FastMutex> _lock(m_fileMutex); + Mantid::Kernel::LockGuardMutex _lock(m_fileMutex); m_ReadOnly = true; if (mode.find("w") != std::string::npos || mode.find("W") != std::string::npos) { @@ -332,7 +332,7 @@ void BoxControllerNeXusIO::saveGenericBlock( // Specify the dimensions std::vector<int64_t> dims(m_BlockSize); - Poco::ScopedLock<Poco::FastMutex> _lock(m_fileMutex); + Mantid::Kernel::LockGuardMutex _lock(m_fileMutex); start[0] = int64_t(blockPosition); dims[0] = int64_t(DataBlock.size() / this->getNDataColums()); @@ -384,7 +384,7 @@ void BoxControllerNeXusIO::loadGenericBlock(std::vector<Type> &Block, std::vector<int64_t> start(2, 0); std::vector<int64_t> size(m_BlockSize); - Poco::ScopedLock<Poco::FastMutex> _lock(m_fileMutex); + Mantid::Kernel::LockGuardMutex _lock(m_fileMutex); start[0] = static_cast<int64_t>(blockPosition); size[0] = static_cast<int64_t>(nPoints); @@ -457,7 +457,7 @@ void BoxControllerNeXusIO::loadBlock(std::vector<double> &Block, /// Clear NeXus internal cache void BoxControllerNeXusIO::flushData() const { - Poco::ScopedLock<Poco::FastMutex> _lock(m_fileMutex); + Mantid::Kernel::LockGuardMutex _lock(m_fileMutex); m_File->flush(); } /** flush disk buffer data from memory and close underlying NeXus file*/ @@ -466,7 +466,7 @@ void BoxControllerNeXusIO::closeFile() { // write all file-backed data still stack in the data buffer into the file. this->flushCache(); // lock file - Poco::ScopedLock<Poco::FastMutex> _lock(m_fileMutex); + Mantid::Kernel::LockGuardMutex _lock(m_fileMutex); { m_File->closeData(); // close events data diff --git a/Framework/DataObjects/src/EventWorkspaceMRU.cpp b/Framework/DataObjects/src/EventWorkspaceMRU.cpp index 6025691a5f8..0ae1ef7c0ff 100644 --- a/Framework/DataObjects/src/EventWorkspaceMRU.cpp +++ b/Framework/DataObjects/src/EventWorkspaceMRU.cpp @@ -4,8 +4,6 @@ namespace Mantid { namespace DataObjects { -using Mantid::Kernel::Mutex; - //---------------------------------------------------------------------------------------------- /** Constructor */ @@ -41,7 +39,7 @@ EventWorkspaceMRU::~EventWorkspaceMRU() { * @param thread_num :: thread number that wants a MRU buffer */ void EventWorkspaceMRU::ensureEnoughBuffersE(size_t thread_num) const { - Mutex::ScopedLock _lock(m_changeMruListsMutexE); + Mantid::Kernel::LockGuardMutex _lock(m_changeMruListsMutexE); if (m_bufferedDataE.size() <= thread_num) { m_bufferedDataE.resize(thread_num + 1, nullptr); for (auto &data : m_bufferedDataE) { @@ -56,7 +54,7 @@ void EventWorkspaceMRU::ensureEnoughBuffersE(size_t thread_num) const { * @param thread_num :: thread number that wants a MRU buffer */ void EventWorkspaceMRU::ensureEnoughBuffersY(size_t thread_num) const { - Mutex::ScopedLock _lock(m_changeMruListsMutexY); + Mantid::Kernel::LockGuardMutex _lock(m_changeMruListsMutexY); if (m_bufferedDataY.size() <= thread_num) { m_bufferedDataY.resize(thread_num + 1, nullptr); for (auto &data : m_bufferedDataY) { @@ -69,7 +67,7 @@ void EventWorkspaceMRU::ensureEnoughBuffersY(size_t thread_num) const { //--------------------------------------------------------------------------- /// Clear all the data in the MRU buffers void EventWorkspaceMRU::clear() { - Mutex::ScopedLock _lock(this->m_toDeleteMutex); + Mantid::Kernel::LockGuardMutex _lock(this->m_toDeleteMutex); // FIXME: don't clear the locked ones! for (auto &marker : m_markersToDelete) @@ -98,7 +96,7 @@ void EventWorkspaceMRU::clear() { *found. */ MantidVecWithMarker *EventWorkspaceMRU::findY(size_t thread_num, size_t index) { - Mutex::ScopedLock _lock(m_changeMruListsMutexY); + Mantid::Kernel::LockGuardMutex _lock(m_changeMruListsMutexY); return m_bufferedDataY[thread_num]->find(index); } @@ -110,7 +108,7 @@ MantidVecWithMarker *EventWorkspaceMRU::findY(size_t thread_num, size_t index) { *found. */ MantidVecWithMarker *EventWorkspaceMRU::findE(size_t thread_num, size_t index) { - Mutex::ScopedLock _lock(m_changeMruListsMutexE); + Mantid::Kernel::LockGuardMutex _lock(m_changeMruListsMutexE); return m_bufferedDataE[thread_num]->find(index); } @@ -122,12 +120,12 @@ MantidVecWithMarker *EventWorkspaceMRU::findE(size_t thread_num, size_t index) { *needs to be deleted. */ void EventWorkspaceMRU::insertY(size_t thread_num, MantidVecWithMarker *data) { - Mutex::ScopedLock _lock(m_changeMruListsMutexY); + Mantid::Kernel::LockGuardMutex _lock(m_changeMruListsMutexY); MantidVecWithMarker *oldData = m_bufferedDataY[thread_num]->insert(data); // And clear up the memory of the old one, if it is dropping out. if (oldData) { if (oldData->m_locked) { - Mutex::ScopedLock _lock(this->m_toDeleteMutex); + Mantid::Kernel::LockGuardMutex _lock(this->m_toDeleteMutex); m_markersToDelete.push_back(oldData); } else delete oldData; @@ -142,12 +140,12 @@ void EventWorkspaceMRU::insertY(size_t thread_num, MantidVecWithMarker *data) { *needs to be deleted. */ void EventWorkspaceMRU::insertE(size_t thread_num, MantidVecWithMarker *data) { - Mutex::ScopedLock _lock(m_changeMruListsMutexE); + Mantid::Kernel::LockGuardMutex _lock(m_changeMruListsMutexE); MantidVecWithMarker *oldData = m_bufferedDataE[thread_num]->insert(data); // And clear up the memory of the old one, if it is dropping out. if (oldData) { if (oldData->m_locked) { - Mutex::ScopedLock _lock(this->m_toDeleteMutex); + Mantid::Kernel::LockGuardMutex _lock(this->m_toDeleteMutex); m_markersToDelete.push_back(oldData); } else delete oldData; @@ -159,11 +157,11 @@ void EventWorkspaceMRU::insertE(size_t thread_num, MantidVecWithMarker *data) { * @param index :: index to delete. */ void EventWorkspaceMRU::deleteIndex(size_t index) { - Mutex::ScopedLock _lock1(m_changeMruListsMutexE); + Mantid::Kernel::LockGuardMutex _lock1(m_changeMruListsMutexE); for (auto &data : m_bufferedDataE) if (data) data->deleteIndex(index); - Mutex::ScopedLock _lock2(m_changeMruListsMutexY); + Mantid::Kernel::LockGuardMutex _lock2(m_changeMruListsMutexY); for (auto &data : m_bufferedDataY) if (data) data->deleteIndex(index); diff --git a/Framework/DataObjects/src/PeakColumn.cpp b/Framework/DataObjects/src/PeakColumn.cpp index a286997ae9e..eadb912c98b 100644 --- a/Framework/DataObjects/src/PeakColumn.cpp +++ b/Framework/DataObjects/src/PeakColumn.cpp @@ -4,8 +4,6 @@ #include "MantidKernel/ConfigService.h" #include "MantidKernel/Exception.h" -#include <Poco/Mutex.h> - #include <boost/variant/get.hpp> using namespace Mantid::Kernel; -- GitLab