summaryrefslogtreecommitdiff
path: root/src/lib/writer.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-01-30 22:54:38 +0100
committerCarl Hetherington <cth@carlh.net>2020-01-30 22:54:38 +0100
commitea6b2dae46caa1da829fbf499e83cd6ae3b3773a (patch)
treef8f978b762fad664a4c8d5fdc11d8c7145ee09a8 /src/lib/writer.cc
parenta1546fb6c4e59621d99271b8ca996e96a574f7b3 (diff)
Various thread cleanups.
Diffstat (limited to 'src/lib/writer.cc')
-rw-r--r--src/lib/writer.cc16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index cc645c8b0..d85db5689 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -68,7 +68,6 @@ using namespace dcpomatic;
Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
: _film (film)
, _job (j)
- , _thread (0)
, _finish (false)
, _queued_full_in_memory (0)
/* These will be reset to sensible values when J2KEncoder is created */
@@ -107,9 +106,9 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
void
Writer::start ()
{
- _thread = new boost::thread (boost::bind (&Writer::thread, this));
+ _thread = boost::thread (boost::bind(&Writer::thread, this));
#ifdef DCPOMATIC_LINUX
- pthread_setname_np (_thread->native_handle(), "writer");
+ pthread_setname_np (_thread.native_handle(), "writer");
#endif
}
@@ -465,7 +464,7 @@ void
Writer::terminate_thread (bool can_throw)
{
boost::mutex::scoped_lock lock (_state_mutex);
- if (_thread == 0) {
+ if (!_thread.joinable()) {
return;
}
@@ -474,22 +473,17 @@ Writer::terminate_thread (bool can_throw)
_full_condition.notify_all ();
lock.unlock ();
- if (_thread->joinable ()) {
- _thread->join ();
- }
+ _thread.join ();
if (can_throw) {
rethrow ();
}
-
- delete _thread;
- _thread = 0;
}
void
Writer::finish ()
{
- if (!_thread) {
+ if (!_thread.joinable()) {
return;
}