summaryrefslogtreecommitdiff
path: root/jvmfwk/plugins/sunmajor
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-23 10:29:19 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-02-23 10:47:36 +0100
commit0a5dcfe4a1955879f9a0d08ab5f2e826e9d4c2b9 (patch)
tree4df47e0483757942f67b24bc55bdb35680710d24 /jvmfwk/plugins/sunmajor
parentf7afe3b7b07800d130b4d9102f2a94ccac0ebc52 (diff)
Adapted AsynchReader to safer-to-use salhelper::Thread
Diffstat (limited to 'jvmfwk/plugins/sunmajor')
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index d541bea22816..a3176fa41362 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -31,13 +31,13 @@
#include "osl/process.h"
#include "osl/security.hxx"
-#include "osl/thread.hxx"
#include "osl/file.hxx"
#include "osl/module.hxx"
#include "rtl/byteseq.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/instance.hxx"
-#include <salhelper/linkhelper.hxx>
+#include "salhelper/linkhelper.hxx"
+#include "salhelper/thread.hxx"
#include "boost/scoped_array.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include <utility>
@@ -294,7 +294,7 @@ FileHandleReader::readLine(rtl::OString * pLine)
}
}
-class AsynchReader: public Thread
+class AsynchReader: public salhelper::Thread
{
size_t m_nDataSize;
boost::scoped_array<sal_Char> m_arData;
@@ -303,7 +303,9 @@ class AsynchReader: public Thread
bool m_bDone;
FileHandleGuard m_aGuard;
- void SAL_CALL run();
+ virtual ~AsynchReader() {}
+
+ void execute();
public:
AsynchReader(oslFileHandle & rHandle);
@@ -317,17 +319,17 @@ public:
};
AsynchReader::AsynchReader(oslFileHandle & rHandle):
- m_nDataSize(0), m_bError(false), m_bDone(false), m_aGuard(rHandle)
+ Thread("jvmfwkAsyncReader"), m_nDataSize(0), m_bError(false),
+ m_bDone(false), m_aGuard(rHandle)
{
}
OString AsynchReader::getData()
{
- OSL_ASSERT(isRunning() == sal_False );
return OString(m_arData.get(), m_nDataSize);
}
-void AsynchReader::run()
+void AsynchReader::execute()
{
const sal_uInt64 BUFFER_SIZE = 4096;
sal_Char aBuffer[BUFFER_SIZE];
@@ -420,7 +422,7 @@ bool getJavaProps(const OUString & exePath,
oslFileHandle fileErr= 0;
FileHandleReader stdoutReader(fileOut);
- AsynchReader stderrReader(fileErr);
+ rtl::Reference< AsynchReader > stderrReader(new AsynchReader(fileErr));
JFW_TRACE2(OUSTR("\n[Java framework] Executing: ") + exePath + OUSTR(".\n"));
oslProcessError procErr =
@@ -450,7 +452,7 @@ bool getJavaProps(const OUString & exePath,
}
//Start asynchronous reading (different thread) of error stream
- stderrReader.create();
+ stderrReader->launch();
//Use this thread to read output stream
FileHandleReader::Result rs = FileHandleReader::RESULT_OK;
@@ -489,9 +491,9 @@ bool getJavaProps(const OUString & exePath,
ret = true;
//process error stream data
- stderrReader.join();
+ stderrReader->join();
JFW_TRACE2("[Java framework] Java wrote to stderr:\" "
- << stderrReader.getData().getStr() << " \".\n");
+ << stderrReader->getData().getStr() << " \".\n");
TimeValue waitMax= {5 ,0};
procErr = osl_joinProcessWithTimeout(javaProcess, &waitMax);