summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-23 10:28:28 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-02-23 10:47:35 +0100
commit123c59342c7191ae7972b76da2ccd28788ac7cee (patch)
tree35f3b378b7f3e0353c14b937ef7af2c00e9e7c28 /pyuno
parenta342b3e3b0c4c2baa40442ab4580f5091c6231d1 (diff)
Adapted GCThread to safer-to-use salhelper::Thread
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/prj/build.lst2
-rw-r--r--pyuno/source/module/makefile.mk1
-rw-r--r--pyuno/source/module/pyuno_gc.cxx50
3 files changed, 27 insertions, 26 deletions
diff --git a/pyuno/prj/build.lst b/pyuno/prj/build.lst
index a7c1c5b03426..8d0f8ba31525 100644
--- a/pyuno/prj/build.lst
+++ b/pyuno/prj/build.lst
@@ -1,4 +1,4 @@
-bgpu pyuno : stoc cpputools cppuhelper bridges tools PYTHON:python LIBXSLT:libxslt NULL
+bgpu pyuno : salhelper stoc cpputools cppuhelper bridges tools PYTHON:python LIBXSLT:libxslt NULL
pu pyuno usr1 - all br_mkout NULL
pu pyuno\zipcore nmake - all pu_zipcore NULL
pu pyuno\source\module nmake - all pu_module NULL
diff --git a/pyuno/source/module/makefile.mk b/pyuno/source/module/makefile.mk
index 714a120de58d..5c9d81e7f032 100644
--- a/pyuno/source/module/makefile.mk
+++ b/pyuno/source/module/makefile.mk
@@ -92,6 +92,7 @@ SHL1STDLIBS= \
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALLIB) \
+ $(SALHELPERLIB) \
$(PYTHONLIB) \
$(EXTRA_FRAMEWORK_FLAG)
diff --git a/pyuno/source/module/pyuno_gc.cxx b/pyuno/source/module/pyuno_gc.cxx
index 6ee657e17835..cd911877545a 100644
--- a/pyuno/source/module/pyuno_gc.cxx
+++ b/pyuno/source/module/pyuno_gc.cxx
@@ -25,8 +25,14 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <pyuno_impl.hxx>
-#include <osl/thread.hxx>
+
+#include "pyuno_impl.hxx"
+
+#include "sal/config.h"
+
+#include "rtl/ref.hxx"
+#include "salhelper/thread.hxx"
+
namespace pyuno
{
@@ -47,25 +53,25 @@ static bool isAfterUnloadOrPy_Finalize()
!Py_IsInitialized();
}
-class GCThread : public ::osl::Thread
-{
- PyObject *mPyObject;
- PyInterpreterState *mPyInterpreter;
- GCThread( const GCThread & ); // not implemented
- GCThread &operator =( const GCThread & ); // not implemented
-
+class GCThread: public salhelper::Thread {
public:
GCThread( PyInterpreterState *interpreter, PyObject * object );
- virtual void SAL_CALL run();
- virtual void SAL_CALL onTerminated();
-};
+private:
+ virtual ~GCThread() {}
+
+ virtual void execute();
+
+ PyObject *mPyObject;
+ PyInterpreterState *mPyInterpreter;
+};
GCThread::GCThread( PyInterpreterState *interpreter, PyObject * object ) :
- mPyObject( object ), mPyInterpreter( interpreter )
+ Thread( "pyunoGCThread" ), mPyObject( object ),
+ mPyInterpreter( interpreter )
{}
-void GCThread::run()
+void GCThread::execute()
{
// otherwise we crash here, when main has been left already
if( isAfterUnloadOrPy_Finalize() )
@@ -95,12 +101,6 @@ void GCThread::run()
}
}
-
-void GCThread::onTerminated()
-{
- delete this;
-}
-
void decreaseRefCount( PyInterpreterState *interpreter, PyObject *object )
{
// otherwise we crash in the last after main ...
@@ -111,11 +111,11 @@ void decreaseRefCount( PyInterpreterState *interpreter, PyObject *object )
// to be a method, which tells, whether the global
// interpreter lock is held or not
// TODO: Look for a more efficient solution
- osl::Thread *t = new GCThread( interpreter, object );
- // don't call create() because Valgrind complains about invalid read in
- // the rather bizarre GCThread::onTerminated; try a lame workaround:
- t->createSuspended();
- t->resume();
+ rtl::Reference< GCThread >(new GCThread(interpreter, object))->launch();
+ //TODO: a protocol is missing how to join with the launched thread
+ // before exit(3), to ensure the thread is no longer relying on any
+ // infrastructure while that infrastructure is being shut down in
+ // atexit handlers
}
}