Mercurial > hg > svcore
changeset 536:beb51f558e9c
* Change QMutex in Editable DTDM to a read/write lock
author | Chris Cannam |
---|---|
date | Mon, 26 Jan 2009 15:18:32 +0000 |
parents | 3ccf48fb81d6 |
children | 3cc4b7cd2aa5 |
files | data/fft/FFTDataServer.cpp data/model/EditableDenseThreeDimensionalModel.cpp data/model/EditableDenseThreeDimensionalModel.h |
diffstat | 3 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp Fri Jan 23 14:00:29 2009 +0000 +++ b/data/fft/FFTDataServer.cpp Mon Jan 26 15:18:32 2009 +0000 @@ -27,8 +27,8 @@ #include "base/Profiler.h" #include "base/Thread.h" // for debug mutex locker -#define DEBUG_FFT_SERVER 1 -#define DEBUG_FFT_SERVER_FILL 1 +//#define DEBUG_FFT_SERVER 1 +//#define DEBUG_FFT_SERVER_FILL 1 #ifdef DEBUG_FFT_SERVER_FILL #ifndef DEBUG_FFT_SERVER
--- a/data/model/EditableDenseThreeDimensionalModel.cpp Fri Jan 23 14:00:29 2009 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Mon Jan 26 15:18:32 2009 +0000 @@ -19,6 +19,8 @@ #include <QTextStream> #include <QStringList> +#include <QReadLocker> +#include <QWriteLocker> #include <iostream> @@ -71,7 +73,7 @@ Model * EditableDenseThreeDimensionalModel::clone() const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); EditableDenseThreeDimensionalModel *model = new EditableDenseThreeDimensionalModel @@ -145,7 +147,7 @@ EditableDenseThreeDimensionalModel::Column EditableDenseThreeDimensionalModel::getColumn(size_t index) const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (index >= m_data.size()) return Column(); return expandAndRetrieve(index); } @@ -308,7 +310,7 @@ EditableDenseThreeDimensionalModel::setColumn(size_t index, const Column &values) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); while (index >= m_data.size()) { m_data.push_back(Column()); @@ -391,7 +393,7 @@ bool EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); QVector<float> sample; QVector<int> n; @@ -450,7 +452,7 @@ QString EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter) const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); QString s; for (size_t i = 0; i < m_data.size(); ++i) { QStringList list; @@ -467,7 +469,7 @@ QString indent, QString extraAttributes) const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); // For historical reasons we read and write "resolution" as "windowSize"
--- a/data/model/EditableDenseThreeDimensionalModel.h Fri Jan 23 14:00:29 2009 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.h Mon Jan 26 15:18:32 2009 +0000 @@ -18,6 +18,8 @@ #include "DenseThreeDimensionalModel.h" +#include <QReadWriteLock> + #include <vector> class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel @@ -167,7 +169,7 @@ long m_sinceLastNotifyMax; int m_completion; - mutable QMutex m_mutex; + mutable QReadWriteLock m_lock; }; #endif