Another macOS std::list boost::thread SNAFU.
[dcpomatic.git] / src / lib / monitor_checker.cc
index 19d8d8181943faaef5e58494d98b1a690c68feb5..d15dee63f99f7d0ba9dbb0a7e60d1b11ebde45b2 100644 (file)
 #include "config.h"
 #include "cross.h"
 
-using boost::bind;
-using boost::ref;
-
 MonitorChecker* MonitorChecker::_instance = 0;
 
 MonitorChecker::MonitorChecker ()
-       : _thread (0)
-       , _terminate (false)
-       , _ok (true)
+       : Checker (60)
 {
 
 }
 
-void
-MonitorChecker::run ()
-{
-       _thread = new boost::thread (boost::bind (&MonitorChecker::thread, this));
-}
-
-MonitorChecker::~MonitorChecker ()
-{
-       {
-               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;
-}
-
-void
-MonitorChecker::thread ()
-{
-       while (true) {
-               boost::mutex::scoped_lock lm (_mutex);
-               if (_terminate) {
-                       break;
-               }
-
-               bool const was_ok = _ok;
-               _ok = Config::instance()->required_monitors().empty() || get_monitors() == Config::instance()->required_monitors();
-               if (was_ok != _ok) {
-                       emit (bind(boost::ref(StateChanged)));
-               }
-
-               lm.unlock ();
-               dcpomatic_sleep (60);
-       }
-}
-
 bool
-MonitorChecker::ok () const
+MonitorChecker::check () const
 {
-       boost::mutex::scoped_lock lm (_mutex);
-       return _ok;
+       return Config::instance()->required_monitors().empty() || get_monitors() == Config::instance()->required_monitors();
 }
 
+
 MonitorChecker *
 MonitorChecker::instance ()
 {