Mercurial > hg > svcore
changeset 1865:7b6e18380e8f startup-timing
Make it possible to check whether the transforms have been populated yet
author | Chris Cannam |
---|---|
date | Wed, 03 Jun 2020 13:57:50 +0100 |
parents | 166d7a4c2cd6 |
children | cb9209ef373a |
files | transform/TransformFactory.cpp transform/TransformFactory.h |
diffstat | 2 files changed, 29 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/TransformFactory.cpp Wed Jun 03 13:57:37 2020 +0100 +++ b/transform/TransformFactory.cpp Wed Jun 03 13:57:50 2020 +0100 @@ -102,7 +102,9 @@ TransformFactory::UninstalledTransformsPopulateThread::run() { m_factory->m_populatingSlowly = true; - sleep(1); + while (!m_factory->havePopulated()) { + sleep(1); + } m_factory->populateUninstalledTransforms(); } @@ -324,6 +326,13 @@ return tr("Other"); } +bool +TransformFactory::havePopulated() +{ + MutexLocker locker(&m_transformsMutex, "TransformFactory::havePopulated"); + return m_transformsPopulated; +} + void TransformFactory::populateTransforms() { @@ -395,6 +404,12 @@ } m_transformsPopulated = true; + +#ifdef DEBUG_TRANSFORM_FACTORY + SVCERR << "populateTransforms exiting" << endl; +#endif + + emit transformsPopulated(); } void @@ -743,6 +758,8 @@ #ifdef DEBUG_TRANSFORM_FACTORY SVCERR << "populateUninstalledTransforms exiting" << endl; #endif + + emit uninstalledTransformsPopulated(); } Transform
--- a/transform/TransformFactory.h Wed Jun 03 13:57:37 2020 +0100 +++ b/transform/TransformFactory.h Wed Jun 03 13:57:50 2020 +0100 @@ -78,6 +78,13 @@ typedef std::map<TransformId, TextMatcher::Match> SearchResults; SearchResults search(QString keyword); SearchResults search(QStringList keywords); + + /** + * Return true if the transforms have been populated, i.e. a call + * to something like haveTransform() will return without having to + * do the work of scanning plugins + */ + bool havePopulated(); /** * Return true if the given transform is known. @@ -191,6 +198,10 @@ QString getStartupFailureReport() const { return m_errorString; } + +signals: + void transformsPopulated(); + void uninstalledTransformsPopulated(); protected: typedef std::map<TransformId, TransformDescription> TransformDescriptionMap;