diff options
Diffstat (limited to 'comphelper/source/misc/asyncnotification.cxx')
-rw-r--r-- | comphelper/source/misc/asyncnotification.cxx | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/comphelper/source/misc/asyncnotification.cxx b/comphelper/source/misc/asyncnotification.cxx index e498ce23ba44..72c6414e7281 100644 --- a/comphelper/source/misc/asyncnotification.cxx +++ b/comphelper/source/misc/asyncnotification.cxx @@ -18,9 +18,9 @@ */ #include <comphelper/asyncnotification.hxx> +#include <comphelper/scopeguard.hxx> #include <mutex> #include <condition_variable> -#include <osl/mutex.hxx> #include <cassert> #include <stdexcept> @@ -91,7 +91,7 @@ namespace comphelper std::scoped_lock aGuard( m_xImpl->aMutex ); // remove all events for this processor - m_xImpl->aEvents.erase(std::remove_if( m_xImpl->aEvents.begin(), m_xImpl->aEvents.end(), EqualProcessor( _xProcessor ) ), m_xImpl->aEvents.end()); + std::erase_if( m_xImpl->aEvents, EqualProcessor( _xProcessor ) ); } @@ -231,26 +231,20 @@ namespace comphelper { // see salhelper::Thread::launch xThis->m_xImpl->pKeepThisAlive = xThis; - try { - if (!xThis->create()) { - throw std::runtime_error("osl::Thread::create failed"); - } - } catch (...) { - xThis->m_xImpl->pKeepThisAlive.reset(); - throw; + comphelper::ScopeGuard g([&xThis] { xThis->m_xImpl->pKeepThisAlive.reset(); }); + if (!xThis->create()) { + throw std::runtime_error("osl::Thread::create failed"); } + g.dismiss(); } void AsyncEventNotifierAutoJoin::run() { // see salhelper::Thread::run - try { - setName(m_xImpl->name); - execute(); - } catch (...) { - onTerminated(); - throw; - } + comphelper::ScopeGuard g([this] { onTerminated(); }); + setName(m_xImpl->name); + execute(); + g.dismiss(); } void AsyncEventNotifierAutoJoin::onTerminated() |