summaryrefslogtreecommitdiff
path: root/src/wx/content_view.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-11-15 23:41:22 +0000
committerCarl Hetherington <cth@carlh.net>2018-11-22 23:26:18 +0000
commit63bce67bd548f4aff98e2a1963e1fd77a6412a15 (patch)
tree44cb9fddd35817db51f79685a67b50050cddd56c /src/wx/content_view.cc
parent620b7761a33d2e3641cd911bfe58e0fbb928c888 (diff)
Speed up content discovery:
1. add all discovery jobs immediately rather than waiting for each one to finish (by polling) before starting the next. 2. replace polling with a condition in JobManager.
Diffstat (limited to 'src/wx/content_view.cc')
-rw-r--r--src/wx/content_view.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc
index e1503e790..b7f05020b 100644
--- a/src/wx/content_view.cc
+++ b/src/wx/content_view.cc
@@ -34,6 +34,7 @@
using std::string;
using std::cout;
+using std::list;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::optional;
@@ -82,6 +83,8 @@ ContentView::update ()
wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory"));
JobManager* jm = JobManager::instance ();
+ list<shared_ptr<ExamineContentJob> > jobs;
+
for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
try {
shared_ptr<Content> content;
@@ -92,21 +95,9 @@ ContentView::update ()
}
if (content) {
- jm->add (shared_ptr<Job>(new ExamineContentJob(film, content)));
- while (jm->work_to_do()) {
- if (!progress.Pulse()) {
- /* user pressed cancel */
- BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
- i->cancel();
- }
- return;
- }
- dcpomatic_sleep (1);
- }
- if (report_errors_from_last_job (this)) {
- add (content);
- _content.push_back (content);
- }
+ shared_ptr<ExamineContentJob> job(new ExamineContentJob(film, content));
+ jm->add (job);
+ jobs.push_back (job);
}
} catch (boost::filesystem::filesystem_error& e) {
/* Never mind */
@@ -114,6 +105,26 @@ ContentView::update ()
/* Never mind */
}
}
+
+ while (jm->work_to_do()) {
+ if (!progress.Pulse()) {
+ /* user pressed cancel */
+ BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
+ i->cancel();
+ }
+ return;
+ }
+ dcpomatic_sleep (1);
+ }
+
+ /* Add content from successful jobs and report errors */
+ BOOST_FOREACH (shared_ptr<ExamineContentJob> i, jobs) {
+ if (i->finished_in_error()) {
+ error_dialog(this, std_to_wx(i->error_summary()) + ".\n", std_to_wx(i->error_details()));
+ } else {
+ add (i->content());
+ }
+ }
}
void