-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);
- }
-}
-