Mercurial > hg > svcore
diff data/fft/FFTDataServer.cpp @ 244:85bf384db35f
* Update to use new vamp-hostsdk instead of vamp-sdk
* Make spectrogram adapt its paint block size depending on how long it actually
takes to draw
* Some thread debugging infrastructure
author | Chris Cannam |
---|---|
date | Fri, 02 Mar 2007 13:01:41 +0000 |
parents | 3e6fee4e4257 |
children | d7eeffbb8aaf |
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp Thu Mar 01 17:12:50 2007 +0000 +++ b/data/fft/FFTDataServer.cpp Fri Mar 02 13:01:41 2007 +0000 @@ -25,11 +25,11 @@ #include "base/StorageAdviser.h" #include "base/Exceptions.h" #include "base/Profiler.h" +#include "base/Thread.h" // for debug mutex locker #include <QMessageBox> #include <QApplication> - //#define DEBUG_FFT_SERVER 1 //#define DEBUG_FFT_SERVER_FILL 1 @@ -39,6 +39,7 @@ #endif #endif + FFTDataServer::ServerMap FFTDataServer::m_servers; FFTDataServer::ServerQueue FFTDataServer::m_releasedServers; QMutex FFTDataServer::m_serverMapMutex; @@ -63,7 +64,7 @@ FFTDataServer *server = 0; - QMutexLocker locker(&m_serverMapMutex); + MutexLocker locker(&m_serverMapMutex, "FFTDataServer::m_serverMapMutex[getInstance]"); if ((server = findServer(n))) { return server; @@ -138,7 +139,7 @@ // or 1536, the model doesn't support this). { - QMutexLocker locker(&m_serverMapMutex); + MutexLocker locker(&m_serverMapMutex, "FFTDataServer::m_serverMapMutex[getFuzzyInstance]"); ServerMap::iterator best = m_servers.end(); int bestdist = -1; @@ -255,7 +256,8 @@ void FFTDataServer::claimInstance(FFTDataServer *server, bool needLock) { - QMutexLocker locker(needLock ? &m_serverMapMutex : 0); + MutexLocker locker(needLock ? &m_serverMapMutex : 0, + "FFTDataServer::m_serverMapMutex[claimInstance]"); #ifdef DEBUG_FFT_SERVER std::cerr << "FFTDataServer::claimInstance(" << server << ")" << std::endl; @@ -299,7 +301,8 @@ void FFTDataServer::releaseInstance(FFTDataServer *server, bool needLock) { - QMutexLocker locker(needLock ? &m_serverMapMutex : 0); + MutexLocker locker(needLock ? &m_serverMapMutex : 0, + "FFTDataServer::m_serverMapMutex[releaseInstance]"); #ifdef DEBUG_FFT_SERVER std::cerr << "FFTDataServer::releaseInstance(" << server << ")" << std::endl; @@ -426,7 +429,8 @@ void FFTDataServer::modelAboutToBeDeleted(Model *model) { - QMutexLocker locker(&m_serverMapMutex); + MutexLocker locker(&m_serverMapMutex, + "FFTDataServer::m_serverMapMutex[modelAboutToBeDeleted]"); #ifdef DEBUG_FFT_SERVER std::cerr << "FFTDataServer::modelAboutToBeDeleted(" << model << ")" @@ -618,7 +622,8 @@ delete m_fillThread; } - QMutexLocker locker(&m_writeMutex); + MutexLocker locker(&m_writeMutex, + "FFTDataServer::m_writeMutex[~FFTDataServer]"); for (CacheVector::iterator i = m_caches.begin(); i != m_caches.end(); ++i) { if (*i) { @@ -658,7 +663,8 @@ #endif Profiler profiler("FFTDataServer::suspend", false); - QMutexLocker locker(&m_writeMutex); + MutexLocker locker(&m_writeMutex, + "FFTDataServer::m_writeMutex[suspend]"); m_suspended = true; for (CacheVector::iterator i = m_caches.begin(); i != m_caches.end(); ++i) { if (*i) (*i)->suspend(); @@ -704,7 +710,8 @@ std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "])::getCacheAux" << std::endl; #endif - QMutexLocker locker(&m_writeMutex); + MutexLocker locker(&m_writeMutex, + "FFTDataServer::m_writeMutex[getCacheAux]"); if (m_lastUsedCache == -1) { m_fillThread->start(); @@ -982,7 +989,8 @@ FFTCache *cache = getCache(x, col); if (!cache) return; - QMutexLocker locker(&m_writeMutex); + MutexLocker locker(&m_writeMutex, + "FFTDataServer::m_writeMutex[fillColumn]"); if (cache->haveSetColumnAt(col)) return; @@ -1142,9 +1150,11 @@ #ifdef DEBUG_FFT_SERVER std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "]): suspended, waiting..." << std::endl; #endif - m_server.m_writeMutex.lock(); - m_server.m_condition.wait(&m_server.m_writeMutex, 10000); - m_server.m_writeMutex.unlock(); + { + MutexLocker locker(&m_server.m_writeMutex, + "FFTDataServer::m_writeMutex[run/1]"); + m_server.m_condition.wait(&m_server.m_writeMutex, 10000); + } #ifdef DEBUG_FFT_SERVER std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "]): waited" << std::endl; #endif @@ -1176,9 +1186,11 @@ #ifdef DEBUG_FFT_SERVER std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "]): suspended, waiting..." << std::endl; #endif - m_server.m_writeMutex.lock(); - m_server.m_condition.wait(&m_server.m_writeMutex, 10000); - m_server.m_writeMutex.unlock(); + { + MutexLocker locker(&m_server.m_writeMutex, + "FFTDataServer::m_writeMutex[run/2]"); + m_server.m_condition.wait(&m_server.m_writeMutex, 10000); + } if (m_server.m_exiting) return; }