diff options
author | sb <sb@openoffice.org> | 2011-01-27 13:48:12 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2011-01-27 13:48:12 +0100 |
commit | 31e39528c76c9cdeb532c8e2974653400daab162 (patch) | |
tree | 4b750975a6ca1ae92bf69ba652aa0bb559df9262 /extensions/source/oooimprovement/onlogrotate_job.cxx | |
parent | 5f85b4a7ea9c43500655b2124df26603a51c0802 (diff) |
sb138: #i116659# timely termination of OnLogRotateThread
Diffstat (limited to 'extensions/source/oooimprovement/onlogrotate_job.cxx')
-rw-r--r-- | extensions/source/oooimprovement/onlogrotate_job.cxx | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/extensions/source/oooimprovement/onlogrotate_job.cxx b/extensions/source/oooimprovement/onlogrotate_job.cxx index 8b73c7ff1..33b9700e9 100644 --- a/extensions/source/oooimprovement/onlogrotate_job.cxx +++ b/extensions/source/oooimprovement/onlogrotate_job.cxx @@ -37,7 +37,7 @@ #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XTerminateListener.hpp> -#include <osl/mutex.hxx> +#include <osl/conditn.hxx> #include <osl/thread.hxx> #include <osl/time.h> #include <cppuhelper/implbase1.hxx> @@ -108,49 +108,41 @@ namespace public: OnLogRotateThread(Reference<XMultiServiceFactory> sf); virtual void SAL_CALL run(); - OnLogRotateThread* disposing(); + void stop(); private: Reference<XMultiServiceFactory> m_ServiceFactory; - ::osl::Mutex m_ServiceFactoryMutex; + ::osl::Condition m_Stop; }; OnLogRotateThread::OnLogRotateThread(Reference<XMultiServiceFactory> sf) : m_ServiceFactory(sf) - { } + { + OSL_ASSERT(sf.is()); + } void SAL_CALL OnLogRotateThread::run() { + TimeValue wait_intervall = {30,0}; + if (m_Stop.wait(&wait_intervall) == ::osl::Condition::result_timeout) { - ::osl::Thread::yield(); - TimeValue wait_intervall = {30,0}; - osl_waitThread(&wait_intervall); - } - { - ::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex); try { - if(m_ServiceFactory.is()) + if(Config(m_ServiceFactory).getInvitationAccepted()) { - if(Config(m_ServiceFactory).getInvitationAccepted()) - { - packLogs(m_ServiceFactory); - uploadLogs(m_ServiceFactory); - } - else - LogStorage(m_ServiceFactory).clear(); + packLogs(m_ServiceFactory); + uploadLogs(m_ServiceFactory); } - m_ServiceFactory.clear(); + else + LogStorage(m_ServiceFactory).clear(); } catch(...) {} } } - OnLogRotateThread* OnLogRotateThread::disposing() + void OnLogRotateThread::stop() { - ::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex); - m_ServiceFactory.clear(); - return this; + m_Stop.set(); } class OnLogRotateThreadWatcher : public ::cppu::WeakImplHelper1<XTerminateListener> @@ -163,7 +155,7 @@ namespace } virtual ~OnLogRotateThreadWatcher() { - m_Thread->disposing()->terminate(); + m_Thread->stop(); m_Thread->join(); }; @@ -172,13 +164,13 @@ namespace { }; virtual void SAL_CALL notifyTermination(const EventObject&) throw(RuntimeException) { - m_Thread->disposing()->terminate(); + m_Thread->stop(); m_Thread->join(); }; // XEventListener virtual void SAL_CALL disposing(const EventObject&) throw(RuntimeException) { - m_Thread->disposing()->terminate(); + m_Thread->stop(); m_Thread->join(); }; private: |