diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-01-30 22:54:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-01-30 22:54:38 +0100 |
| commit | ea6b2dae46caa1da829fbf499e83cd6ae3b3773a (patch) | |
| tree | f8f978b762fad664a4c8d5fdc11d8c7145ee09a8 /src/lib/update_checker.cc | |
| parent | a1546fb6c4e59621d99271b8ca996e96a574f7b3 (diff) | |
Various thread cleanups.
Diffstat (limited to 'src/lib/update_checker.cc')
| -rw-r--r-- | src/lib/update_checker.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lib/update_checker.cc b/src/lib/update_checker.cc index 98e407822..82337f920 100644 --- a/src/lib/update_checker.cc +++ b/src/lib/update_checker.cc @@ -56,7 +56,6 @@ UpdateChecker::UpdateChecker () , _curl (0) , _state (NOT_RUN) , _emits (0) - , _thread (0) , _to_do (0) , _terminate (false) { @@ -74,9 +73,9 @@ UpdateChecker::UpdateChecker () void UpdateChecker::start () { - _thread = new boost::thread (boost::bind (&UpdateChecker::thread, this)); + _thread = boost::thread (boost::bind (&UpdateChecker::thread, this)); #ifdef DCPOMATIC_LINUX - pthread_setname_np (_thread->native_handle(), "update-checker"); + pthread_setname_np (_thread.native_handle(), "update-checker"); #endif } @@ -88,15 +87,13 @@ UpdateChecker::~UpdateChecker () } _condition.notify_all (); - if (_thread) { - /* Ideally this would be a DCPOMATIC_ASSERT(_thread->joinable()) but we - can't throw exceptions from a destructor. - */ - if (_thread->joinable ()) { - _thread->join (); + if (_thread.joinable()) { + try { + _thread.join (); + } catch (...) { + } } - delete _thread; curl_easy_cleanup (_curl); delete[] _buffer; |
