Move the code to find Liberation into util.cc.
[dcpomatic.git] / src / lib / checker.cc
index 2d15dd3f1e1adae3fed945674cfff9676498d3ba..b96b965aab2efc3ced2bafbc6eed596ad11e67c0 100644 (file)
@@ -28,8 +28,7 @@ using boost::bind;
 using boost::ref;
 
 Checker::Checker (int period)
-       : _thread (0)
-       , _terminate (false)
+       : _terminate (false)
        , _ok (true)
        , _period (period)
 {
@@ -39,30 +38,22 @@ Checker::Checker (int period)
 void
 Checker::run ()
 {
-       _thread = new boost::thread (boost::bind (&Checker::thread, this));
+       _thread = boost::thread (boost::bind(&Checker::thread, this));
 }
 
 Checker::~Checker ()
 {
+       boost::this_thread::disable_interruption dis;
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _terminate = true;
        }
 
-       if (_thread) {
-               /* Ideally this would be a DCPOMATIC_ASSERT(_thread->joinable()) but we
-                  can't throw exceptions from a destructor.
-               */
-               _thread->interrupt ();
-               try {
-                       if (_thread->joinable ()) {
-                               _thread->join ();
-                       }
-               } catch (boost::thread_interrupted& e) {
-                       /* No problem */
-               }
-       }
-       delete _thread;
+       _thread.interrupt ();
+       try {
+               _thread.join ();
+       } catch (...) {}
 }
 
 void