summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-23 10:25:39 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-02-23 10:47:35 +0100
commita342b3e3b0c4c2baa40442ab4580f5091c6231d1 (patch)
treed2498fe7a445ddabd70ee5a8bf778e719c839116
parent5b98bb47139588d2b8ca31060f9d48377a4fbfdc (diff)
Moved dp_gui::Thread to salhelper::Thread, so that all code can use it
...also improved the code somewhat.
-rw-r--r--desktop/Library_deploymentgui.mk1
-rw-r--r--desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx18
-rw-r--r--desktop/source/deployment/gui/dp_gui_thread.cxx83
-rw-r--r--desktop/source/deployment/gui/dp_gui_thread.hxx87
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.cxx8
-rw-r--r--desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx8
-rw-r--r--sal/inc/osl/thread.hxx7
-rw-r--r--sal/inc/sal/log-areas.dox1
-rw-r--r--salhelper/Library_salhelper.mk1
-rw-r--r--salhelper/Package_inc.mk1
-rw-r--r--salhelper/inc/salhelper/thread.hxx104
-rw-r--r--salhelper/source/gcc3.map18
-rw-r--r--salhelper/source/thread.cxx66
13 files changed, 207 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),
diff --git a/sal/inc/osl/thread.hxx b/sal/inc/osl/thread.hxx
index 2916ff7443d6..0bade3b06c86 100644
--- a/sal/inc/osl/thread.hxx
+++ b/sal/inc/osl/thread.hxx
@@ -49,6 +49,13 @@ namespace osl
*/
extern "C" inline void SAL_CALL threadFunc( void* param);
+/**
+ A thread abstraction.
+
+ @deprecated use ::salhelper::Thread instead. Only the static member
+ functions ::osl::Thread::getCurrentIdentifier, ::osl::Thread::wait, and
+ ::osl::Thread::yield are not deprecated.
+ */
class Thread
{
Thread( const Thread& );
diff --git a/sal/inc/sal/log-areas.dox b/sal/inc/sal/log-areas.dox
index e397836881d5..246b9692a50c 100644
--- a/sal/inc/sal/log-areas.dox
+++ b/sal/inc/sal/log-areas.dox
@@ -35,6 +35,7 @@ certain functionality.
@section URE
@li @c rtl.string - ::rtl::OString, ::rtl::OUString, and related functionality
+@li @c salhelper.thread - ::salhelper::Thread class
@section VCL
diff --git a/salhelper/Library_salhelper.mk b/salhelper/Library_salhelper.mk
index d98cd220f037..e899685185af 100644
--- a/salhelper/Library_salhelper.mk
+++ b/salhelper/Library_salhelper.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Library_add_exception_objects,salhelper,\
salhelper/source/condition \
salhelper/source/dynload \
salhelper/source/simplereferenceobject \
+ salhelper/source/thread \
salhelper/source/timer \
))
diff --git a/salhelper/Package_inc.mk b/salhelper/Package_inc.mk
index 744489ce25ad..37c3da5fc3a4 100644
--- a/salhelper/Package_inc.mk
+++ b/salhelper/Package_inc.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/queue.hxx,queue.hx
$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/refobj.hxx,refobj.hxx))
$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/simplereferenceobject.hxx,simplereferenceobject.hxx))
$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/singletonref.hxx,singletonref.hxx))
+$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/thread.hxx,thread.hxx))
$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/timer.hxx,timer.hxx))
# vim: set noet sw=4 ts=4:
diff --git a/salhelper/inc/salhelper/thread.hxx b/salhelper/inc/salhelper/thread.hxx
new file mode 100644
index 000000000000..619ac449ef17
--- /dev/null
+++ b/salhelper/inc/salhelper/thread.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com>
+ * (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef INCLUDED_SALHELPER_THREAD_HXX
+#define INCLUDED_SALHELPER_THREAD_HXX
+
+#include "sal/config.h"
+
+#include <cstddef>
+
+#include "osl/thread.hxx"
+#include "sal/types.h"
+#include "salhelper/salhelperdllapi.h"
+#include "salhelper/simplereferenceobject.hxx"
+
+namespace salhelper {
+
+/**
+ A safe encapsulation of ::osl::Thread.
+
+ @since LibreOffice 3.6
+*/
+class SALHELPER_DLLPUBLIC Thread:
+ public salhelper::SimpleReferenceObject, private osl::Thread
+{
+public:
+ /**
+ @param name the thread name, see ::osl_setThreadName; must be a non-null
+ null terminated string
+ */
+ Thread(char const * name);
+
+ /**
+ Launch the thread.
+
+ This function must be called at most once.
+
+ Each call of this function should eventually be followed by a call to
+ ::osl::Thread::join before exit(3), to ensure the thread is no longer
+ relying on any infrastructure while that infrastructure is being shut
+ down in atexit handlers.
+ */
+ void launch();
+
+ using osl::Thread::getIdentifier;
+ using osl::Thread::join;
+ using osl::Thread::schedule;
+ using osl::Thread::terminate;
+
+ static inline void * operator new(std::size_t size)
+ { return SimpleReferenceObject::operator new(size); }
+
+ static inline void operator delete(void * pointer)
+ { SimpleReferenceObject::operator delete(pointer); }
+
+protected:
+ virtual ~Thread();
+
+ /**
+ The main function executed by the thread.
+
+ Any uncaught exceptions lead to std::terminate.
+ */
+ virtual void execute() = 0;
+
+private:
+ virtual void SAL_CALL run();
+
+ virtual void SAL_CALL onTerminated();
+
+ char const * name_;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/salhelper/source/gcc3.map b/salhelper/source/gcc3.map
index a4617835d488..c356dc651f59 100644
--- a/salhelper/source/gcc3.map
+++ b/salhelper/source/gcc3.map
@@ -96,6 +96,24 @@ UDK_3.1 {
} UDK_3_0_0;
+LIBO_UDK_3.6 { # symbols available in >= LibO 3.6
+ global:
+ _ZN9salhelper6Thread12onTerminatedEv;
+ # salhelper::Thread::onTerminated()
+ _ZN9salhelper6Thread3runEv; # salhelper::Thread::run()
+ _ZN9salhelper6Thread6launchEv; # salhelper::Thread::launch()
+ _ZN9salhelper6ThreadC1EPKc; # salhelper::Thread::Thread(char const*)
+ _ZN9salhelper6ThreadC2EPKc; # salhelper::Thread::Thread(char const*)
+ _ZN9salhelper6ThreadD0Ev; # salhelper::Thread::~Thread()
+ _ZN9salhelper6ThreadD1Ev; # salhelper::Thread::~Thread()
+ _ZN9salhelper6ThreadD2Ev; # salhelper::Thread::~Thread()
+ _ZTVN9salhelper6ThreadE; # vtable for salhelper::Thread
+ _ZThn16_N9salhelper6Thread12onTerminatedEv;
+ # non-virtual thunk to salhelper::Thread::onTerminated()
+ _ZThn16_N9salhelper6Thread3runEv;
+ # non-virtual thunk to salhelper::Thread::run()
+} UDK_3.1;
+
# Unique libstdc++ symbols:
GLIBCXX_3.4 {
global:
diff --git a/salhelper/source/thread.cxx b/salhelper/source/thread.cxx
new file mode 100644
index 000000000000..bf7c1f196aa8
--- /dev/null
+++ b/salhelper/source/thread.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com>
+ * (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "sal/config.h"
+
+#include "sal/log.hxx"
+#include "salhelper/thread.hxx"
+
+salhelper::Thread::Thread(char const * name): name_(name) {}
+
+void salhelper::Thread::launch() {
+ SAL_INFO("salhelper.thread", "launch " << name_);
+ // Assumption is that osl::Thread::create returns normally iff it causes
+ // osl::Thread::run to start executing:
+ acquire();
+ try {
+ create();
+ } catch (...) {
+ release();
+ throw;
+ }
+}
+
+salhelper::Thread::~Thread() {}
+
+void salhelper::Thread::run() {
+ try {
+ setName(name_);
+ execute();
+ } catch (...) {
+ // Work around the problem that onTerminated is not called if run throws
+ // an exception:
+ onTerminated();
+ throw;
+ }
+}
+
+void salhelper::Thread::onTerminated() { release(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */