diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-03-06 20:59:58 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-03-06 20:59:58 +0000 |
| commit | e03d6f9bc6af9dfa8602c82cc52040a92144deaf (patch) | |
| tree | 3ca44d6b77f8e9184063d7cd29d849b1f7b290c3 /src/lib | |
| parent | b93430a73313d705f7f51315db705cfcf9942297 (diff) | |
Destroy Job threads at the start of the subclass destructors,
so that the thread is gone before the object is torn down.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/analyse_audio_job.cc | 1 | ||||
| -rw-r--r-- | src/lib/check_content_change_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/check_content_change_job.h | 1 | ||||
| -rw-r--r-- | src/lib/examine_content_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/examine_content_job.h | 1 | ||||
| -rw-r--r-- | src/lib/examine_ffmpeg_subtitles_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/examine_ffmpeg_subtitles_job.h | 1 | ||||
| -rw-r--r-- | src/lib/job.cc | 10 | ||||
| -rw-r--r-- | src/lib/job.h | 1 | ||||
| -rw-r--r-- | src/lib/send_kdm_email_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/send_kdm_email_job.h | 2 | ||||
| -rw-r--r-- | src/lib/send_notification_email_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/send_notification_email_job.h | 1 | ||||
| -rw-r--r-- | src/lib/send_problem_report_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/send_problem_report_job.h | 2 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/transcode_job.h | 1 | ||||
| -rw-r--r-- | src/lib/upload_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/upload_job.h | 1 | ||||
| -rw-r--r-- | src/lib/verify_dcp_job.cc | 5 | ||||
| -rw-r--r-- | src/lib/verify_dcp_job.h | 1 |
21 files changed, 68 insertions, 0 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index e4a100c4a..611a57f5b 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -82,6 +82,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const AnalyseAudioJob::~AnalyseAudioJob () { + destroy_thread (); BOOST_FOREACH (Filter const * i, _filters) { delete const_cast<Filter*> (i); } diff --git a/src/lib/check_content_change_job.cc b/src/lib/check_content_change_job.cc index 3d5e4e979..fbeb695df 100644 --- a/src/lib/check_content_change_job.cc +++ b/src/lib/check_content_change_job.cc @@ -41,6 +41,11 @@ CheckContentChangeJob::CheckContentChangeJob (shared_ptr<const Film> film, share } +CheckContentChangeJob::~CheckContentChangeJob() +{ + destroy_thread (); +} + string CheckContentChangeJob::name () const { diff --git a/src/lib/check_content_change_job.h b/src/lib/check_content_change_job.h index da9c5cb20..963d09b59 100644 --- a/src/lib/check_content_change_job.h +++ b/src/lib/check_content_change_job.h @@ -28,6 +28,7 @@ class CheckContentChangeJob : public Job { public: CheckContentChangeJob (boost::shared_ptr<const Film>, boost::shared_ptr<Job> following = boost::shared_ptr<Job>()); + ~CheckContentChangeJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index 86e0a107e..5c854a99b 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -38,6 +38,11 @@ ExamineContentJob::ExamineContentJob (shared_ptr<const Film> film, shared_ptr<Co } +ExamineContentJob::~ExamineContentJob () +{ + destroy_thread (); +} + string ExamineContentJob::name () const { diff --git a/src/lib/examine_content_job.h b/src/lib/examine_content_job.h index 424963726..0105035ff 100644 --- a/src/lib/examine_content_job.h +++ b/src/lib/examine_content_job.h @@ -27,6 +27,7 @@ class ExamineContentJob : public Job { public: ExamineContentJob (boost::shared_ptr<const Film>, boost::shared_ptr<Content>); + ~ExamineContentJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/examine_ffmpeg_subtitles_job.cc b/src/lib/examine_ffmpeg_subtitles_job.cc index b9d5f54e5..eb2cbcd1f 100644 --- a/src/lib/examine_ffmpeg_subtitles_job.cc +++ b/src/lib/examine_ffmpeg_subtitles_job.cc @@ -43,6 +43,11 @@ ExamineFFmpegSubtitlesJob::ExamineFFmpegSubtitlesJob (shared_ptr<const Film> fil } +ExamineFFmpegSubtitlesJob::~ExamineFFmpegSubtitlesJob () +{ + destroy_thread (); +} + string ExamineFFmpegSubtitlesJob::name () const { diff --git a/src/lib/examine_ffmpeg_subtitles_job.h b/src/lib/examine_ffmpeg_subtitles_job.h index 5960a9cc3..0a0101193 100644 --- a/src/lib/examine_ffmpeg_subtitles_job.h +++ b/src/lib/examine_ffmpeg_subtitles_job.h @@ -28,6 +28,7 @@ class ExamineFFmpegSubtitlesJob : public Job, public FFmpeg { public: ExamineFFmpegSubtitlesJob (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>); + ~ExamineFFmpegSubtitlesJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/job.cc b/src/lib/job.cc index 451776524..d4023973c 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -62,6 +62,15 @@ Job::Job (shared_ptr<const Film> film) Job::~Job () { +#ifdef DCPOMATIC_DEBUG + /* Any subclass should have called destroy_thread in its destructor */ + assert (!_thread); +#endif +} + +void +Job::destroy_thread () +{ if (_thread) { _thread->interrupt (); /* We can't use DCPOMATIC_ASSERT here as it may throw an exception */ @@ -75,6 +84,7 @@ Job::~Job () } delete _thread; + _thread = 0; } /** Start the job in a separate thread, returning immediately */ diff --git a/src/lib/job.h b/src/lib/job.h index 0e57021e0..7047a7ba3 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -112,6 +112,7 @@ protected: void set_message (std::string m); int elapsed_sub_time () const; void check_for_interruption_or_pause (); + void destroy_thread (); boost::shared_ptr<const Film> _film; diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 38484b91e..a4b4b297f 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -53,6 +53,11 @@ SendKDMEmailJob::SendKDMEmailJob ( } +SendKDMEmailJob::~SendKDMEmailJob () +{ + destroy_thread (); +} + string SendKDMEmailJob::name () const { diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h index b4e007e3b..fcb9a0b9e 100644 --- a/src/lib/send_kdm_email_job.h +++ b/src/lib/send_kdm_email_job.h @@ -38,6 +38,8 @@ public: std::string cpl_name ); + ~SendKDMEmailJob (); + std::string name () const; std::string json_name () const; void run (); diff --git a/src/lib/send_notification_email_job.cc b/src/lib/send_notification_email_job.cc index abbb844e2..5986e5a16 100644 --- a/src/lib/send_notification_email_job.cc +++ b/src/lib/send_notification_email_job.cc @@ -40,6 +40,11 @@ SendNotificationEmailJob::SendNotificationEmailJob (string body) } +SendNotificationEmailJob::~SendNotificationEmailJob () +{ + destroy_thread (); +} + string SendNotificationEmailJob::name () const { diff --git a/src/lib/send_notification_email_job.h b/src/lib/send_notification_email_job.h index 04f1d98ab..5c116f2ee 100644 --- a/src/lib/send_notification_email_job.h +++ b/src/lib/send_notification_email_job.h @@ -24,6 +24,7 @@ class SendNotificationEmailJob : public Job { public: explicit SendNotificationEmailJob (std::string body); + ~SendNotificationEmailJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc index 11f700de0..83092049f 100644 --- a/src/lib/send_problem_report_job.cc +++ b/src/lib/send_problem_report_job.cc @@ -52,6 +52,11 @@ SendProblemReportJob::SendProblemReportJob ( } +SendProblemReportJob::~SendProblemReportJob () +{ + destroy_thread (); +} + string SendProblemReportJob::name () const { diff --git a/src/lib/send_problem_report_job.h b/src/lib/send_problem_report_job.h index c4371a54e..af1a4b269 100644 --- a/src/lib/send_problem_report_job.h +++ b/src/lib/send_problem_report_job.h @@ -31,6 +31,8 @@ public: std::string summary ); + ~SendProblemReportJob (); + std::string name () const; std::string json_name () const; void run (); diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 1db37e370..f2711bf17 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -51,6 +51,11 @@ TranscodeJob::TranscodeJob (shared_ptr<const Film> film) } +TranscodeJob::~TranscodeJob () +{ + destroy_thread (); +} + string TranscodeJob::name () const { diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h index 9dd9e3684..fccb1a44a 100644 --- a/src/lib/transcode_job.h +++ b/src/lib/transcode_job.h @@ -34,6 +34,7 @@ class TranscodeJob : public Job { public: explicit TranscodeJob (boost::shared_ptr<const Film> film); + ~TranscodeJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index b229fddbe..eca46838d 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -46,6 +46,11 @@ UploadJob::UploadJob (shared_ptr<const Film> film) } +UploadJob::~UploadJob () +{ + destroy_thread (); +} + string UploadJob::name () const { diff --git a/src/lib/upload_job.h b/src/lib/upload_job.h index 407094ab8..3a613fd72 100644 --- a/src/lib/upload_job.h +++ b/src/lib/upload_job.h @@ -28,6 +28,7 @@ class UploadJob : public Job { public: explicit UploadJob (boost::shared_ptr<const Film>); + ~UploadJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/verify_dcp_job.cc b/src/lib/verify_dcp_job.cc index 5fb2a59c1..03d9c4c4c 100644 --- a/src/lib/verify_dcp_job.cc +++ b/src/lib/verify_dcp_job.cc @@ -35,6 +35,11 @@ VerifyDCPJob::VerifyDCPJob (vector<boost::filesystem::path> directories) } +VerifyDCPJob::~VerifyDCPJob () +{ + destroy_thread (); +} + string VerifyDCPJob::name () const { diff --git a/src/lib/verify_dcp_job.h b/src/lib/verify_dcp_job.h index a93a7adfa..2cff5ab6c 100644 --- a/src/lib/verify_dcp_job.h +++ b/src/lib/verify_dcp_job.h @@ -28,6 +28,7 @@ class VerifyDCPJob : public Job { public: explicit VerifyDCPJob (std::vector<boost::filesystem::path> directories); + ~VerifyDCPJob (); std::string name () const; std::string json_name () const; |
