mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: replace recursive QMutex-es with std::recursive_mutex-es [ci reset]
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4b0b6cbe6a
commit
ebf69fb68e
9 changed files with 70 additions and 73 deletions
|
@ -53,7 +53,6 @@
|
|||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QCache>
|
||||
|
@ -61,6 +60,8 @@
|
|||
#include <QtCore/QSettings>
|
||||
#include <QtNetwork/QHostInfo>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#define case_sensitivity Qt::CaseSensitive
|
||||
|
||||
#ifndef PATH_MAX
|
||||
|
@ -73,7 +74,6 @@ public:
|
|||
KStandardDirsPrivate(KStandardDirs* qq)
|
||||
: m_restrictionsActive(false),
|
||||
m_checkRestrictions(true),
|
||||
m_cacheMutex(QMutex::Recursive), // resourceDirs is recursive
|
||||
q(qq)
|
||||
{ }
|
||||
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
// Caches (protected by mutex in const methods, cf ctor docu)
|
||||
QMap<QByteArray, QStringList> m_dircache;
|
||||
QMap<QByteArray, QString> m_savelocations;
|
||||
QMutex m_cacheMutex;
|
||||
std::recursive_mutex m_cacheMutex; // resourceDirs is recursive
|
||||
|
||||
KStandardDirs* q;
|
||||
};
|
||||
|
@ -917,7 +917,7 @@ QStringList KStandardDirs::resourceDirs(const char *type) const
|
|||
|
||||
QStringList KStandardDirs::KStandardDirsPrivate::resourceDirs(const char* type, const QString& subdirForRestrictions)
|
||||
{
|
||||
QMutexLocker lock(&m_cacheMutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_cacheMutex);
|
||||
const bool dataRestrictionActive = m_restrictionsActive
|
||||
&& (strcmp(type, "data") == 0)
|
||||
&& hasDataRestrictions(subdirForRestrictions);
|
||||
|
@ -1226,7 +1226,7 @@ QString KStandardDirs::saveLocation(const char *type,
|
|||
const QString& suffix,
|
||||
bool create) const
|
||||
{
|
||||
QMutexLocker lock(&d->m_cacheMutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(d->m_cacheMutex);
|
||||
QString path = d->m_savelocations.value(type);
|
||||
if (path.isEmpty())
|
||||
{
|
||||
|
|
|
@ -41,9 +41,10 @@
|
|||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QLocale>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "kcatalog_p.h"
|
||||
#include "kglobal.h"
|
||||
#include "kstandarddirs.h"
|
||||
|
@ -307,7 +308,7 @@ void KLocalePrivate::initConfig(KConfig *config)
|
|||
void KLocalePrivate::initMainCatalogs()
|
||||
{
|
||||
KLocaleStaticData *s = staticData;
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
|
||||
if (!s->maincatalog.isEmpty()) {
|
||||
// If setMainCatalog was called, then we use that
|
||||
|
@ -629,7 +630,7 @@ bool KLocalePrivate::setCountryDivisionCode(const QString &countryDivisionCode)
|
|||
|
||||
bool KLocalePrivate::setLanguage(const QString &language, KConfig *config)
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
m_languageList.removeAll(language);
|
||||
m_languageList.prepend(language); // let us consider this language to be the most important one
|
||||
|
||||
|
@ -655,7 +656,7 @@ bool KLocalePrivate::setLanguage(const QString &language, KConfig *config)
|
|||
// config so this can be reparsed when required.
|
||||
bool KLocalePrivate::setLanguage(const QStringList &languages)
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
// This list might contain
|
||||
// 1) some empty strings that we have to eliminate
|
||||
// 2) duplicate entries like in de:fr:de, where we have to keep the first occurrence of a
|
||||
|
@ -806,7 +807,7 @@ QString KLocalePrivate::currencyCode() const
|
|||
|
||||
void KLocalePrivate::insertCatalog(const QString &catalog)
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
int pos = m_catalogNames.indexOf(KCatalogName(catalog));
|
||||
if (pos != -1) {
|
||||
++m_catalogNames[pos].loadCount;
|
||||
|
@ -855,7 +856,7 @@ void KLocalePrivate::updateCatalogs()
|
|||
|
||||
void KLocalePrivate::removeCatalog(const QString &catalog)
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
int pos = m_catalogNames.indexOf(KCatalogName(catalog));
|
||||
if (pos == -1) {
|
||||
return;
|
||||
|
@ -872,7 +873,7 @@ void KLocalePrivate::removeCatalog(const QString &catalog)
|
|||
|
||||
void KLocalePrivate::setActiveCatalog(const QString &catalog)
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
int pos = m_catalogNames.indexOf(KCatalogName(catalog));
|
||||
if (pos == -1) {
|
||||
return;
|
||||
|
@ -901,7 +902,7 @@ void KLocalePrivate::translateRawFrom(const char *catname, const char *msgctxt,
|
|||
<< "Fix the program" << endl;
|
||||
}
|
||||
|
||||
QMutexLocker locker(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
// determine the fallback string
|
||||
QString fallback;
|
||||
if (msgid_plural == NULL) {
|
||||
|
@ -1702,7 +1703,7 @@ QString KLocalePrivate::formatByteSize(double size, int precision, KLocale::Bina
|
|||
if (dialect == m_binaryUnitDialect) {
|
||||
// Cache default units for speed
|
||||
if (m_byteSizeFmt.size() == 0) {
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
|
||||
// We only cache the user's default dialect.
|
||||
m_byteSizeFmt = dialectUnitsList(m_binaryUnitDialect);
|
||||
|
@ -1756,7 +1757,7 @@ KLocale::BinaryUnitDialect KLocalePrivate::binaryUnitDialect() const
|
|||
void KLocalePrivate::setBinaryUnitDialect(KLocale::BinaryUnitDialect newDialect)
|
||||
{
|
||||
if (newDialect > KLocale::DefaultBinaryDialect && newDialect <= KLocale::LastBinaryDialect) {
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
m_binaryUnitDialect = newDialect;
|
||||
m_byteSizeFmt.clear(); // Reset cached translations.
|
||||
}
|
||||
|
@ -3029,7 +3030,7 @@ KLocale::WeekNumberSystem KLocalePrivate::weekNumberSystem() const
|
|||
|
||||
void KLocalePrivate::copyCatalogsTo(KLocale *locale)
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
locale->d->m_catalogNames = m_catalogNames;
|
||||
locale->d->updateCatalogs();
|
||||
}
|
||||
|
@ -3102,9 +3103,9 @@ KLocale::DigitSet KLocalePrivate::dateTimeDigitSet() const
|
|||
return m_dateTimeDigitSet;
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, s_kLocaleMutex, (QMutex::Recursive))
|
||||
static std::recursive_mutex s_kLocaleMutex;
|
||||
|
||||
QMutex *kLocaleMutex()
|
||||
std::recursive_mutex& kLocaleMutex()
|
||||
{
|
||||
return s_kLocaleMutex();
|
||||
return s_kLocaleMutex;
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#include "klocale.h"
|
||||
#include "kdayperiod_p.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <mutex>
|
||||
|
||||
class KCatalog;
|
||||
|
||||
// Used by both KLocale and KLocalizedString, since they call each other.
|
||||
QMutex* kLocaleMutex();
|
||||
std::recursive_mutex& kLocaleMutex();
|
||||
|
||||
class KLocalePrivate
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ QString KLocalizedString::toString (const KLocale *locale,
|
|||
QString KLocalizedStringPrivate::toString (const KLocale *locale,
|
||||
const QString *catalogName) const
|
||||
{
|
||||
QMutexLocker lock(kLocaleMutex());
|
||||
std::lock_guard<std::recursive_mutex> lock(kLocaleMutex());
|
||||
|
||||
// Assure the message has been supplied.
|
||||
if (msg.isEmpty())
|
||||
|
|
|
@ -49,8 +49,7 @@ KMimeTypeRepository::KMimeTypeRepository()
|
|||
m_mimeTypesChecked(false),
|
||||
m_useFavIcons(true),
|
||||
m_useFavIconsChecked(false),
|
||||
m_sharedMimeInfoVersion(0),
|
||||
m_mutex(QMutex::Recursive)
|
||||
m_sharedMimeInfoVersion(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -195,7 +194,7 @@ QStringList KMimeTypeRepository::findFromFileName(const QString &fileName, QStri
|
|||
{
|
||||
parseGlobs();
|
||||
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
// First try the high weight matches (>50), if any.
|
||||
QStringList matchingMimeTypes;
|
||||
QString foundExt;
|
||||
|
@ -248,7 +247,7 @@ KMimeType::Ptr KMimeTypeRepository::findFromContent(QIODevice* device, int* accu
|
|||
|
||||
// Apply magic rules
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
Q_FOREACH ( const KMimeMagicRule& rule, m_magicRules ) {
|
||||
if (rule.match(device, deviceSize, beginning)) {
|
||||
if (accuracy)
|
||||
|
@ -288,7 +287,7 @@ static QString fallbackParent(const QString& mimeTypeName)
|
|||
|
||||
QStringList KMimeTypeRepository::parents(const QString& mime)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (!m_parentsMapLoaded) {
|
||||
m_parentsMapLoaded = true;
|
||||
Q_ASSERT(m_parents.isEmpty());
|
||||
|
@ -345,7 +344,7 @@ static bool mimeMagicRuleCompare(const KMimeMagicRule& lhs, const KMimeMagicRule
|
|||
|
||||
void KMimeTypeRepository::parseMagic()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (m_magicFilesParsed) {
|
||||
return;
|
||||
}
|
||||
|
@ -549,7 +548,7 @@ QList<KMimeMagicRule> KMimeTypeRepository::parseMagicFile(QIODevice* file, const
|
|||
|
||||
const KMimeTypeRepository::AliasesMap& KMimeTypeRepository::aliases()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (m_aliasFilesParsed) {
|
||||
return m_aliases;
|
||||
}
|
||||
|
@ -589,7 +588,7 @@ const KMimeTypeRepository::AliasesMap& KMimeTypeRepository::aliases()
|
|||
|
||||
void KMimeTypeRepository::parseGlobs()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (m_globsFilesParsed) {
|
||||
return;
|
||||
}
|
||||
|
@ -603,7 +602,7 @@ QStringList KMimeTypeRepository::patternsForMimetype(const QString& mimeType)
|
|||
{
|
||||
parseGlobs();
|
||||
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (!m_patternsMapCalculated) {
|
||||
m_patternsMapCalculated = true;
|
||||
m_patterns = m_globs.patternsMap();
|
||||
|
@ -619,7 +618,7 @@ static void errorMissingMimeTypes( const QStringList& _types )
|
|||
|
||||
void KMimeTypeRepository::checkEssentialMimeTypes()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (m_mimeTypesChecked) { // already done
|
||||
return;
|
||||
}
|
||||
|
@ -663,7 +662,7 @@ void KMimeTypeRepository::checkEssentialMimeTypes()
|
|||
|
||||
KMimeType::Ptr KMimeTypeRepository::defaultMimeTypePtr()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (!m_defaultMimeType) {
|
||||
// Try to find the default type
|
||||
KMimeType::Ptr mime = findMimeTypeByName(KMimeType::defaultMimeType());
|
||||
|
@ -684,7 +683,7 @@ bool KMimeTypeRepository::useFavIcons()
|
|||
{
|
||||
// this method will be called quite often, so better not read the config
|
||||
// again and again.
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (!m_useFavIconsChecked) {
|
||||
m_useFavIconsChecked = true;
|
||||
KConfigGroup cg( KGlobal::config(), "HTML Settings" );
|
||||
|
@ -783,7 +782,7 @@ static int mimeDataBaseVersion()
|
|||
|
||||
int KMimeTypeRepository::sharedMimeInfoVersion()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
if (m_sharedMimeInfoVersion == 0)
|
||||
m_sharedMimeInfoVersion = mimeDataBaseVersion();
|
||||
return m_sharedMimeInfoVersion;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "kmimeglobsfileparser_p.h"
|
||||
#include "kmimetype.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <mutex>
|
||||
|
||||
/**
|
||||
* @internal - this header is not installed
|
||||
|
@ -173,7 +173,7 @@ private:
|
|||
QList<KMimeMagicRule> m_magicRules;
|
||||
KMimeGlobsFileParser::AllGlobs m_globs;
|
||||
KMimeType::Ptr m_defaultMimeType;
|
||||
QMutex m_mutex;
|
||||
std::recursive_mutex m_mutex;
|
||||
};
|
||||
|
||||
#endif /* KMIMETYPEREPOSITORY_H */
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QIcon>
|
||||
#include <QMutex>
|
||||
#include <QSharedData>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "abstractrunner.h"
|
||||
|
||||
namespace Plasma
|
||||
|
@ -39,7 +39,6 @@ class QueryMatchPrivate : public QSharedData
|
|||
public:
|
||||
QueryMatchPrivate(AbstractRunner *r)
|
||||
: QSharedData(),
|
||||
mutex(new QMutex(QMutex::Recursive)),
|
||||
runner(r),
|
||||
type(QueryMatch::ExactMatch),
|
||||
relevance(.7),
|
||||
|
@ -50,10 +49,9 @@ class QueryMatchPrivate : public QSharedData
|
|||
}
|
||||
|
||||
QueryMatchPrivate(const QueryMatchPrivate &other)
|
||||
: QSharedData(other),
|
||||
mutex(new QMutex(QMutex::Recursive))
|
||||
: QSharedData(other)
|
||||
{
|
||||
QMutexLocker lock(other.mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(other.mutex);
|
||||
runner = other.runner;
|
||||
type = other.type;
|
||||
relevance = other.relevance;
|
||||
|
@ -69,10 +67,9 @@ class QueryMatchPrivate : public QSharedData
|
|||
|
||||
~QueryMatchPrivate()
|
||||
{
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
QMutex *mutex;
|
||||
mutable std::recursive_mutex mutex;
|
||||
QWeakPointer<AbstractRunner> runner;
|
||||
QueryMatch::Type type;
|
||||
QString id;
|
||||
|
@ -142,19 +139,19 @@ AbstractRunner* QueryMatch::runner() const
|
|||
|
||||
void QueryMatch::setText(const QString &text)
|
||||
{
|
||||
QMutexLocker locker(d->mutex);
|
||||
std::lock_guard<std::recursive_mutex> locker(d->mutex);
|
||||
d->text = text;
|
||||
}
|
||||
|
||||
void QueryMatch::setSubtext(const QString &subtext)
|
||||
{
|
||||
QMutexLocker locker(d->mutex);
|
||||
std::lock_guard<std::recursive_mutex> locker(d->mutex);
|
||||
d->subtext = subtext;
|
||||
}
|
||||
|
||||
void QueryMatch::setData(const QVariant & data)
|
||||
{
|
||||
QMutexLocker locker(d->mutex);
|
||||
std::lock_guard<std::recursive_mutex> locker(d->mutex);
|
||||
d->data = data;
|
||||
|
||||
if (d->id.isEmpty() || d->idSetByData) {
|
||||
|
@ -168,7 +165,7 @@ void QueryMatch::setData(const QVariant & data)
|
|||
|
||||
void QueryMatch::setId(const QString &id)
|
||||
{
|
||||
QMutexLocker locker(d->mutex);
|
||||
std::lock_guard<std::recursive_mutex> locker(d->mutex);
|
||||
if (d->runner) {
|
||||
d->id = d->runner.data()->id();
|
||||
}
|
||||
|
@ -182,7 +179,7 @@ void QueryMatch::setId(const QString &id)
|
|||
|
||||
void QueryMatch::setIcon(const QIcon &icon)
|
||||
{
|
||||
QMutexLocker locker(d->mutex);
|
||||
std::lock_guard<std::recursive_mutex> locker(d->mutex);
|
||||
d->icon = icon;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,12 +52,11 @@ WeaverImpl::WeaverImpl( QObject* parent )
|
|||
: WeaverInterface(parent)
|
||||
, m_active(0)
|
||||
, m_inventoryMax( qMax(4, 2 * QThread::idealThreadCount() ) )
|
||||
, m_mutex ( new QMutex( QMutex::Recursive ) )
|
||||
, m_finishMutex( new QMutex )
|
||||
, m_jobAvailableMutex ( new QMutex )
|
||||
, m_state (0)
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
// initialize state objects:
|
||||
m_states[InConstruction] = new InConstructionState( this );
|
||||
setState ( InConstruction );
|
||||
|
@ -89,7 +88,7 @@ WeaverImpl::~WeaverImpl()
|
|||
for (;;) {
|
||||
Thread* th = 0;
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
if (m_inventory.isEmpty()) break;
|
||||
th = m_inventory.takeFirst();
|
||||
}
|
||||
|
@ -112,12 +111,11 @@ WeaverImpl::~WeaverImpl()
|
|||
setState ( Destructed ); // m_state = Halted;
|
||||
// FIXME: delete state objects. what sense does DestructedState make then?
|
||||
// FIXME: make state objects static, since they are
|
||||
delete m_mutex;
|
||||
}
|
||||
|
||||
void WeaverImpl::setState ( StateId id )
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
if ( m_state==0 || m_state->stateId() != id )
|
||||
{
|
||||
m_state = m_states[id];
|
||||
|
@ -135,26 +133,26 @@ void WeaverImpl::setState ( StateId id )
|
|||
|
||||
const State& WeaverImpl::state() const
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return *m_state;
|
||||
}
|
||||
|
||||
void WeaverImpl::setMaximumNumberOfThreads( int cap )
|
||||
{
|
||||
Q_ASSERT_X ( cap > 0, "Weaver Impl", "Thread inventory size has to be larger than zero." );
|
||||
QMutexLocker l (m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
m_inventoryMax = cap;
|
||||
}
|
||||
|
||||
int WeaverImpl::maximumNumberOfThreads() const
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return m_inventoryMax;
|
||||
}
|
||||
|
||||
int WeaverImpl::currentNumberOfThreads () const
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return m_inventory.count ();
|
||||
}
|
||||
|
||||
|
@ -177,7 +175,7 @@ void WeaverImpl::enqueue(Job* job)
|
|||
if (job) {
|
||||
adjustInventory ( 1 );
|
||||
kDebug() << "queueing job" << job << "of type " << job->metaObject()->className();
|
||||
QMutexLocker l (m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
job->aboutToBeQueued ( this );
|
||||
// find position for insertion:;
|
||||
// FIXME (after 0.6) optimize: factor out queue management into own class,
|
||||
|
@ -196,7 +194,7 @@ void WeaverImpl::enqueue(Job* job)
|
|||
|
||||
void WeaverImpl::adjustInventory ( int numberOfNewJobs )
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
|
||||
// no of threads that can be created:
|
||||
const int reserve = m_inventoryMax - m_inventory.count();
|
||||
|
@ -230,7 +228,7 @@ bool WeaverImpl::dequeue ( Job* job )
|
|||
{
|
||||
bool result;
|
||||
{
|
||||
QMutexLocker l (m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
|
||||
int i = m_assignments.indexOf ( job );
|
||||
if ( i != -1 )
|
||||
|
@ -255,7 +253,7 @@ bool WeaverImpl::dequeue ( Job* job )
|
|||
void WeaverImpl::dequeue ()
|
||||
{
|
||||
kDebug( "dequeueing all jobs." );
|
||||
QMutexLocker l (m_mutex);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
for ( int index = 0; index < m_assignments.size(); ++index )
|
||||
{
|
||||
m_assignments.at( index )->aboutToBeDequeued( this );
|
||||
|
@ -282,7 +280,7 @@ void WeaverImpl::assignJobs()
|
|||
|
||||
bool WeaverImpl::isEmpty() const
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return m_assignments.isEmpty();
|
||||
}
|
||||
|
||||
|
@ -302,7 +300,7 @@ void WeaverImpl::decActiveThreadCount()
|
|||
|
||||
void WeaverImpl::adjustActiveThreadCount( int diff )
|
||||
{
|
||||
QMutexLocker l (m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
m_active += diff;
|
||||
kDebug() << m_active << "active threads (" << queueLength() << "in queue).";
|
||||
|
||||
|
@ -315,13 +313,13 @@ void WeaverImpl::adjustActiveThreadCount( int diff )
|
|||
|
||||
int WeaverImpl::activeThreadCount()
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return m_active;
|
||||
}
|
||||
|
||||
Job* WeaverImpl::takeFirstAvailableJob(Job *previous)
|
||||
{
|
||||
QMutexLocker l (m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
if (previous) {
|
||||
// cleanup and send events:
|
||||
decActiveThreadCount();
|
||||
|
@ -361,13 +359,13 @@ void WeaverImpl::blockThreadUntilJobsAreBeingAssigned ( Thread *th )
|
|||
|
||||
int WeaverImpl::queueLength() const
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return m_assignments.count();
|
||||
}
|
||||
|
||||
bool WeaverImpl::isIdle () const
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
return isEmpty() && m_active == 0;
|
||||
}
|
||||
|
||||
|
@ -392,7 +390,7 @@ void WeaverImpl::finish()
|
|||
|
||||
void WeaverImpl::requestAbort()
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
for ( int i = 0; i<m_inventory.size(); ++i ) {
|
||||
m_inventory[i]->requestAbort();
|
||||
}
|
||||
|
@ -400,7 +398,7 @@ void WeaverImpl::requestAbort()
|
|||
|
||||
void WeaverImpl::dumpJobs()
|
||||
{
|
||||
QMutexLocker l(m_mutex); Q_UNUSED(l);
|
||||
std::lock_guard<std::recursive_mutex> l(m_mutex);
|
||||
kDebug( "current jobs:" );
|
||||
for ( int index = 0; index < m_assignments.size(); ++index ) {
|
||||
kDebug() << "-->"
|
||||
|
|
|
@ -38,6 +38,8 @@ $Id: WeaverImpl.h 32 2005-08-17 08:38:01Z mirko $
|
|||
#include "State.h"
|
||||
#include "WeaverInterface.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace ThreadWeaver {
|
||||
|
||||
class Job;
|
||||
|
@ -165,7 +167,7 @@ namespace ThreadWeaver {
|
|||
|
||||
private:
|
||||
/** Mutex to serialize operations. */
|
||||
QMutex *m_mutex;
|
||||
mutable std::recursive_mutex m_mutex;
|
||||
|
||||
/** Non-recursive mutex to serialize calls to finish(). */
|
||||
QMutex* m_finishMutex;
|
||||
|
|
Loading…
Add table
Reference in a new issue