Remove several exception-throwing asserts from destructors.
authorCarl Hetherington <cth@carlh.net>
Sun, 3 Jul 2016 19:36:20 +0000 (20:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 3 Jul 2016 19:36:20 +0000 (20:36 +0100)
src/lib/encode_server.cc
src/lib/encode_server_finder.cc
src/lib/job_manager.cc
src/lib/update_checker.cc

index f318da0..7e01520 100644 (file)
@@ -85,15 +85,23 @@ EncodeServer::~EncodeServer ()
        }
 
        BOOST_FOREACH (boost::thread* i, _worker_threads) {
-               DCPOMATIC_ASSERT (i->joinable ());
-               i->join ();
+               /* Ideally this would be a DCPOMATIC_ASSERT(i->joinable()) but we
+                  can't throw exceptions from a destructor.
+               */
+               if (i->joinable ()) {
+                       i->join ();
+               }
                delete i;
        }
 
        _broadcast.io_service.stop ();
        if (_broadcast.thread) {
-               DCPOMATIC_ASSERT (_broadcast.thread->joinable ());
-               _broadcast.thread->join ();
+               /* Ideally this would be a DCPOMATIC_ASSERT(_broadcast.thread->joinable()) but we
+                  can't throw exceptions from a destructor.
+               */
+               if (_broadcast.thread->joinable ()) {
+                       _broadcast.thread->join ();
+               }
        }
 }
 
index 7491d9e..eebf404 100644 (file)
@@ -64,14 +64,22 @@ EncodeServerFinder::~EncodeServerFinder ()
 
        _search_condition.notify_all ();
        if (_search_thread) {
-               DCPOMATIC_ASSERT (_search_thread->joinable ());
-               _search_thread->join ();
+               /* Ideally this would be a DCPOMATIC_ASSERT(_search_thread->joinable()) but we
+                  can't throw exceptions from a destructor.
+               */
+               if (_search_thread->joinable ()) {
+                       _search_thread->join ();
+               }
        }
 
        _listen_io_service.stop ();
        if (_listen_thread) {
-               DCPOMATIC_ASSERT (_listen_thread->joinable ());
-               _listen_thread->join ();
+               /* Ideally this would be a DCPOMATIC_ASSERT(_listen_thread->joinable()) but we
+                  can't throw exceptions from a destructor.
+               */
+               if (_listen_thread->joinable ()) {
+                       _listen_thread->join ();
+               }
        }
 }
 
index 08c744e..c9924d2 100644 (file)
@@ -63,8 +63,12 @@ JobManager::~JobManager ()
        }
 
        if (_scheduler) {
-               DCPOMATIC_ASSERT (_scheduler->joinable ());
-               _scheduler->join ();
+               /* Ideally this would be a DCPOMATIC_ASSERT(_scheduler->joinable()) but we
+                  can't throw exceptions from a destructor.
+               */
+               if (_scheduler->joinable ()) {
+                       _scheduler->join ();
+               }
        }
 
        delete _scheduler;
index e3bbd66..58bc7c1 100644 (file)
@@ -86,8 +86,12 @@ UpdateChecker::~UpdateChecker ()
 
        _condition.notify_all ();
        if (_thread) {
-               DCPOMATIC_ASSERT (_thread->joinable ());
-               _thread->join ();
+               /* Ideally this would be a DCPOMATIC_ASSERT(_thread->joinable()) but we
+                  can't throw exceptions from a destructor.
+               */
+               if (_thread->joinable ()) {
+                       _thread->join ();
+               }
        }
        delete _thread;