index: wait with cleanup until work-queue is empty

This commit is contained in:
Dirk-Jan C. Binnema
2021-01-15 21:05:00 +02:00
parent bcd96d8a1e
commit a3865d6ba9
2 changed files with 21 additions and 4 deletions

View File

@ -268,7 +268,24 @@ Indexer::Private::start(const Indexer::Config& conf)
g_warning ("failed to start scanner"); g_warning ("failed to start scanner");
goto leave; goto leave;
} }
g_debug ("scanner finished"); g_debug ("scanner finished with %zu file(s) in queue",
fq_.size());
}
{
// now there may still be messages in the work queue...
// finish those, but only for a while.
const auto start{std::chrono::steady_clock::now()};
while (!fq_.empty() && std::chrono::steady_clock::now() - start < 10s) {
std::this_thread::sleep_for(100ms);
}
}
if (!fq_.empty()) {
g_warning ("scan takes too long; dropping %zu file(s) from queue",
fq_.size());
fq_.clear();
} }
if (conf_.cleanup) { if (conf_.cleanup) {

View File

@ -65,7 +65,7 @@ public:
~Scanner(); ~Scanner();
/** /**
* Start the scan; this is a blocking call than run until * Start the scan; this is a blocking call than runs until
* finished or (from another thread) stop() is called. * finished or (from another thread) stop() is called.
* *
* @return true if starting worked; false otherwise * @return true if starting worked; false otherwise
@ -87,8 +87,8 @@ public:
bool is_running() const; bool is_running() const;
private: private:
struct Private; struct Private;
std::unique_ptr<Private> priv_; std::unique_ptr<Private> priv_;
}; };
} // namespace Mu } // namespace Mu