diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-02-23 10:25:39 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-02-23 10:47:35 +0100 |
commit | a342b3e3b0c4c2baa40442ab4580f5091c6231d1 (patch) | |
tree | d2498fe7a445ddabd70ee5a8bf778e719c839116 /desktop | |
parent | 5b98bb47139588d2b8ca31060f9d48377a4fbfdc (diff) |
Moved dp_gui::Thread to salhelper::Thread, so that all code can use it
...also improved the code somewhat.
Diffstat (limited to 'desktop')
6 files changed, 9 insertions, 196 deletions
diff --git a/desktop/Library_deploymentgui.mk b/desktop/Library_deploymentgui.mk index 2ce86226d8f3..959484804330 100644 --- a/desktop/Library_deploymentgui.mk +++ b/desktop/Library_deploymentgui.mk @@ -79,7 +79,6 @@ $(eval $(call gb_Library_add_exception_objects,deploymentgui,\ desktop/source/deployment/gui/dp_gui_extlistbox \ desktop/source/deployment/gui/dp_gui_service \ desktop/source/deployment/gui/dp_gui_theextmgr \ - desktop/source/deployment/gui/dp_gui_thread \ desktop/source/deployment/gui/dp_gui_updatedialog \ desktop/source/deployment/gui/dp_gui_updateinstalldialog \ desktop/source/deployment/gui/license_dialog \ diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 62347ce12804..ae37a1d5cb4f 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -71,6 +71,7 @@ #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" +#include "salhelper/thread.hxx" #include "ucbhelper/content.hxx" #include "cppuhelper/exc_hlp.hxx" #include "cppuhelper/implbase3.hxx" @@ -79,7 +80,6 @@ #include "toolkit/helper/vclunohelper.hxx" #include "dp_gui.h" -#include "dp_gui_thread.hxx" #include "dp_gui_extensioncmdqueue.hxx" #include "dp_gui_dependencydialog.hxx" #include "dp_gui_dialog2.hxx" @@ -230,7 +230,7 @@ struct ExtensionCmd typedef ::boost::shared_ptr< ExtensionCmd > TExtensionCmd; //------------------------------------------------------------------------------ -class ExtensionCmdQueue::Thread: public dp_gui::Thread +class ExtensionCmdQueue::Thread: public salhelper::Thread { public: Thread( DialogHelper *pDialogHelper, @@ -249,13 +249,9 @@ public: bool isBusy(); private: - Thread( Thread & ); // not defined - void operator =( Thread & ); // not defined - virtual ~Thread(); virtual void execute(); - virtual void SAL_CALL onTerminated(); void _insert(const TExtensionCmd& rExtCmd); @@ -290,7 +286,6 @@ private: osl::Condition m_wakeup; osl::Mutex m_mutex; Input m_eInput; - bool m_bTerminated; bool m_bStopped; bool m_bWorking; }; @@ -624,6 +619,7 @@ void ProgressCmdEnv::pop() ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, TheExtensionManager *pManager, const uno::Reference< uno::XComponentContext > & rContext ) : + salhelper::Thread( "dp_gui_extensioncmdqueue" ), m_xContext( rContext ), m_pDialogHelper( pDialogHelper ), m_pManager( pManager ), @@ -634,7 +630,6 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, m_sDefaultCmd( DialogHelper::getResourceString( RID_STR_ADD_PACKAGES ) ), m_sAcceptLicense( DialogHelper::getResourceString( RID_STR_ACCEPT_LICENSE ) ), m_eInput( NONE ), - m_bTerminated( false ), m_bStopped( false ), m_bWorking( false ) { @@ -1078,13 +1073,6 @@ void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv {} } -//------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::onTerminated() -{ - ::osl::MutexGuard g(m_mutex); - m_bTerminated = true; -} - void ExtensionCmdQueue::Thread::_insert(const TExtensionCmd& rExtCmd) { ::osl::MutexGuard aGuard( m_mutex ); diff --git a/desktop/source/deployment/gui/dp_gui_thread.cxx b/desktop/source/deployment/gui/dp_gui_thread.cxx deleted file mode 100644 index 6650263d4e48..000000000000 --- a/desktop/source/deployment/gui/dp_gui_thread.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "sal/config.h" - -#include <cstddef> -#include <new> - -#include "osl/thread.hxx" -#include "salhelper/simplereferenceobject.hxx" - -#include "dp_gui_thread.hxx" - -using dp_gui::Thread; - -Thread::Thread() {} - -void Thread::launch() { - // Assumption is that osl::Thread::create returns normally iff it causes - // osl::Thread::run to start executing: - acquire(); - try { - create(); - } catch (...) { - release(); - throw; - } -} - -void * Thread::operator new(std::size_t size) - throw (std::bad_alloc) -{ - return SimpleReferenceObject::operator new(size); -} - -void Thread::operator delete(void * p) throw () { - SimpleReferenceObject::operator delete(p); -} - -Thread::~Thread() {} - -void Thread::run() { - try { - execute(); - } catch (...) { - // Work around the problem that onTerminated is not called if run throws - // an exception: - onTerminated(); - throw; - } -} - -void Thread::onTerminated() { - release(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/gui/dp_gui_thread.hxx b/desktop/source/deployment/gui/dp_gui_thread.hxx deleted file mode 100644 index 624624b0cb3f..000000000000 --- a/desktop/source/deployment/gui/dp_gui_thread.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_THREAD_HXX -#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_THREAD_HXX - -#include "sal/config.h" - -#include <cstddef> -#include <new> -#include "osl/thread.hxx" -#include "sal/types.h" -#include "salhelper/simplereferenceobject.hxx" - -/// @HTML - -namespace dp_gui { - -/** - A safe encapsulation of <code>osl::Thread</code>. -*/ -class Thread: public salhelper::SimpleReferenceObject, private osl::Thread { -public: - Thread(); - - /** - Launch the thread. - - <p>This function must be called at most once.</p> - */ - void launch(); - - using osl::Thread::join; - - static void * operator new(std::size_t size) throw (std::bad_alloc); - - static void operator delete(void * p) throw (); - -protected: - virtual ~Thread(); - - /** - The main function executed by the thread. - - <p>Any exceptions terminate the thread and are effectively ignored.</p> - */ - virtual void execute() = 0; - -private: - Thread(Thread &); // not defined - void operator =(Thread &); // not defined - - virtual void SAL_CALL run(); - - virtual void SAL_CALL onTerminated(); -}; - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 54cc3eace3e5..6805719ad951 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -89,6 +89,7 @@ #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" +#include "salhelper/thread.hxx" #include "svtools/svlbitm.hxx" #include "svtools/svlbox.hxx" #include <svtools/controldims.hrc> @@ -117,7 +118,6 @@ #include "dp_gui.h" #include "dp_gui.hrc" -#include "dp_gui_thread.hxx" #include "dp_gui_updatedata.hxx" #include "dp_gui_updatedialog.hxx" #include "dp_gui_shared.hxx" @@ -210,7 +210,7 @@ UpdateDialog::Index::Index( Kind theKind, sal_uInt16 nID, sal_uInt16 nIndex, con //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -class UpdateDialog::Thread: public dp_gui::Thread { +class UpdateDialog::Thread: public salhelper::Thread { public: Thread( uno::Reference< uno::XComponentContext > const & context, @@ -220,9 +220,6 @@ public: void stop(); private: - Thread(UpdateDialog::Thread &); // not defined - void operator =(UpdateDialog::Thread &); // not defined - virtual ~Thread(); virtual void execute(); @@ -264,6 +261,7 @@ UpdateDialog::Thread::Thread( uno::Reference< uno::XComponentContext > const & context, UpdateDialog & dialog, const std::vector< uno::Reference< deployment::XPackage > > &vExtensionList): + salhelper::Thread("dp_gui_updatedialog"), m_context(context), m_dialog(dialog), m_vExtensionList(vExtensionList), diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index 76c250ee9a51..20172ddd10e8 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -73,12 +73,12 @@ #include "dp_ucb.h" #include "dp_misc.h" #include "dp_version.hxx" -#include "dp_gui_thread.hxx" #include "dp_gui_extensioncmdqueue.hxx" #include "ucbhelper/content.hxx" #include "osl/mutex.hxx" #include "osl/mutex.hxx" #include "rtl/ref.hxx" +#include "salhelper/thread.hxx" #include "com/sun/star/uno/Sequence.h" #include "comphelper/anytostring.hxx" #include "toolkit/helper/vclunohelper.hxx" @@ -95,7 +95,7 @@ using ::rtl::OUString; namespace dp_gui { -class UpdateInstallDialog::Thread: public dp_gui::Thread { +class UpdateInstallDialog::Thread: public salhelper::Thread { friend class UpdateCommandEnv; public: Thread(cssu::Reference< cssu::XComponentContext > ctx, @@ -106,9 +106,6 @@ public: private: - Thread(Thread &); // not defined - void operator =(Thread &); // not defined - virtual ~Thread(); virtual void execute(); @@ -175,6 +172,7 @@ UpdateInstallDialog::Thread::Thread( cssu::Reference< cssu::XComponentContext> xCtx, UpdateInstallDialog & dialog, std::vector< dp_gui::UpdateData > & aVecUpdateData): + salhelper::Thread("dp_gui_updateinstalldialog"), m_dialog(dialog), m_xComponentContext(xCtx), m_aVecUpdateData(aVecUpdateData), |