# HG changeset patch # User Chris Cannam # Date 1226396505 0 # Node ID e0784311a1037f0f741a6d50463c496fdc7ee183 # Parent acddcc3cca362ca8c14133c21b3d672b7e8d58ac * Start thread to populate uninstalled transforms only on request (so runner doesn't have to have it) diff -r acddcc3cca36 -r e0784311a103 rdf/PluginRDFIndexer.cpp --- a/rdf/PluginRDFIndexer.cpp Fri Nov 07 20:25:57 2008 +0000 +++ b/rdf/PluginRDFIndexer.cpp Tue Nov 11 09:41:45 2008 +0000 @@ -52,6 +52,17 @@ PluginRDFIndexer::PluginRDFIndexer() { + indexInstalledURLs(); +} + +PluginRDFIndexer::~PluginRDFIndexer() +{ + QMutexLocker locker(&m_mutex); +} + +void +PluginRDFIndexer::indexInstalledURLs() +{ vector paths = PluginHostAdapter::getPluginPath(); QStringList filters; @@ -98,11 +109,6 @@ } } -PluginRDFIndexer::~PluginRDFIndexer() -{ - QMutexLocker locker(&m_mutex); -} - bool PluginRDFIndexer::indexConfiguredURLs() { diff -r acddcc3cca36 -r e0784311a103 rdf/PluginRDFIndexer.h --- a/rdf/PluginRDFIndexer.h Fri Nov 07 20:25:57 2008 +0000 +++ b/rdf/PluginRDFIndexer.h Tue Nov 11 09:41:45 2008 +0000 @@ -22,8 +22,6 @@ #include #include -//!!!class FileSource; - class PluginRDFIndexer { public: @@ -31,9 +29,11 @@ /** * Index all URLs obtained from index files defined in the current - * settings. This is not done automatically because it may incur - * significant processing and networking effort. It could be - * called from a background thread at startup, for example. + * settings. In contrast to indexing URLs that are installed + * locally alongside plugins, this is not done automatically + * because it may incur significant processing and networking + * effort. It could be called from a background thread at + * startup, for example. * * Note that this class has a single mutex, so other functions * will block if called from a different thread while this one is @@ -55,16 +55,15 @@ protected: PluginRDFIndexer(); QMutex m_mutex; -/*!!! - std::set m_sources; -*/ + typedef std::map StringMap; StringMap m_uriToIdMap; StringMap m_idToUriMap; StringMap m_idToDescriptionMap; + + void indexInstalledURLs(); bool indexFile(QString path); static PluginRDFIndexer *m_instance; -//!!! void expireCacheMaybe(QString); }; #endif diff -r acddcc3cca36 -r e0784311a103 transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Fri Nov 07 20:25:57 2008 +0000 +++ b/transform/TransformFactory.cpp Tue Nov 11 09:41:45 2008 +0000 @@ -51,17 +51,27 @@ TransformFactory::TransformFactory() : m_transformsPopulated(false), - m_uninstalledTransformsPopulated(false) + m_uninstalledTransformsPopulated(false), + m_thread(0) { - UninstalledTransformsPopulateThread *thread = - new UninstalledTransformsPopulateThread(this); - thread->start(); } TransformFactory::~TransformFactory() { } +void +TransformFactory::startPopulationThread() +{ + MutexLocker locker(&m_uninstalledTransformsMutex, + "TransformFactory::startPopulationThread"); + + if (m_thread) return; + + m_thread = new UninstalledTransformsPopulateThread(this); + m_thread->start(); +} + TransformList TransformFactory::getAllTransformDescriptions() { diff -r acddcc3cca36 -r e0784311a103 transform/TransformFactory.h --- a/transform/TransformFactory.h Fri Nov 07 20:25:57 2008 +0000 +++ b/transform/TransformFactory.h Tue Nov 11 09:41:45 2008 +0000 @@ -40,6 +40,18 @@ static TransformFactory *getInstance(); + /** + * TransformFactory has a background thread that can populate + * uninstalled transforms from network RDF resources. It is not + * started by default, but it's a good idea to start it when the + * program starts up, if the uninstalled transforms may be of use + * later; otherwise there will be a bottleneck the first time + * they're requested. + * + * If this thread is not already running, start it now. + */ + void startPopulationThread(); + TransformList getAllTransformDescriptions(); TransformDescription getTransformDescription(TransformId id); @@ -212,6 +224,8 @@ TransformFactory *m_factory; }; + UninstalledTransformsPopulateThread *m_thread; + static TransformFactory *m_instance; };