Kaydet (Commit) d21fb145 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Adapted Reader/Writer to safer-to-use salhelper::Thread

üst 0a5dcfe4
......@@ -106,7 +106,7 @@ extern "C" void SAL_CALL freeProxyCallback(
static_cast< Proxy * >(pProxy)->do_free();
}
void joinThread(osl::Thread * thread) {
void joinThread(salhelper::Thread * thread) {
assert(thread != 0);
if (thread->getIdentifier() != osl::Thread::getCurrentIdentifier()) {
thread->join();
......@@ -239,9 +239,9 @@ void Bridge::start() {
threadPool_ = uno_threadpool_create();
assert(threadPool_ != 0);
writer_.set(new Writer(this));
writer_->create();
writer_->launch();
reader_.set(new Reader(this));
reader_->create();
reader_->launch();
}
void Bridge::terminate() {
......
......@@ -109,15 +109,15 @@ extern "C" void SAL_CALL request(void * pThreadSpecificData) {
}
Reader::Reader(rtl::Reference< Bridge > const & bridge): bridge_(bridge) {
Reader::Reader(rtl::Reference< Bridge > const & bridge):
Thread("binaryurpReader"), bridge_(bridge)
{
assert(bridge.is());
acquire();
}
Reader::~Reader() {}
void Reader::run() {
setName("binaryurpReader");
void Reader::execute() {
try {
bridge_->sendRequestChangeRequest();
css::uno::Reference< css::connection::XConnection > con(
......@@ -153,10 +153,6 @@ void Reader::run() {
bridge_->terminate();
}
void Reader::onTerminated() {
release();
}
void Reader::readMessage(Unmarshal & unmarshal) {
sal_uInt8 flags1 = unmarshal.read8();
bool newType;
......
......@@ -31,15 +31,11 @@
#include "sal/config.h"
#include <cstddef>
#include "boost/noncopyable.hpp"
#include "osl/thread.hxx"
#include "rtl/byteseq.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "salhelper/simplereferenceobject.hxx"
#include "salhelper/thread.hxx"
#include "typelib/typedescription.hxx"
#include "readerstate.hxx"
......@@ -52,25 +48,14 @@ namespace binaryurp {
namespace binaryurp {
class Reader:
public osl::Thread, public salhelper::SimpleReferenceObject,
private boost::noncopyable
{
class Reader: public salhelper::Thread {
public:
static void * operator new(std::size_t size)
{ return Thread::operator new(size); }
static void operator delete(void * pointer)
{ Thread::operator delete(pointer); }
explicit Reader(rtl::Reference< Bridge > const & bridge);
private:
virtual ~Reader();
virtual void SAL_CALL run();
virtual void SAL_CALL onTerminated();
virtual void execute();
void readMessage(Unmarshal & unmarshal);
......
......@@ -77,10 +77,10 @@ Writer::Item::Item(
{}
Writer::Writer(rtl::Reference< Bridge > const & bridge):
bridge_(bridge), marshal_(bridge, state_), stop_(false)
Thread("binaryurpWriter"), bridge_(bridge), marshal_(bridge, state_),
stop_(false)
{
OSL_ASSERT(bridge.is());
acquire();
}
void Writer::sendDirectRequest(
......@@ -148,8 +148,7 @@ void Writer::stop() {
Writer::~Writer() {}
void Writer::run() {
setName("binaryurpWriter");
void Writer::execute() {
try {
unblocked_.wait();
for (;;) {
......@@ -199,10 +198,6 @@ void Writer::run() {
bridge_->terminate();
}
void Writer::onTerminated() {
release();
}
void Writer::sendRequest(
rtl::ByteSequence const & tid, rtl::OUString const & oid,
css::uno::TypeDescription const & type,
......
......@@ -31,19 +31,15 @@
#include "sal/config.h"
#include <cstddef>
#include <deque>
#include <vector>
#include "boost/noncopyable.hpp"
#include "osl/conditn.hxx"
#include "osl/mutex.hxx"
#include "osl/thread.hxx"
#include "rtl/byteseq.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "salhelper/simplereferenceobject.hxx"
#include "salhelper/thread.hxx"
#include "typelib/typedescription.hxx"
#include "uno/dispatcher.hxx"
......@@ -55,17 +51,9 @@ namespace binaryurp { class Bridge; }
namespace binaryurp {
class Writer:
public osl::Thread, public salhelper::SimpleReferenceObject,
private boost::noncopyable
class Writer: public salhelper::Thread
{
public:
static void * operator new(std::size_t size)
{ return Thread::operator new(size); }
static void operator delete(void * pointer)
{ Thread::operator delete(pointer); }
explicit Writer(rtl::Reference< Bridge > const & bridge);
// Only called from Bridge::reader_ thread, and only before Bridge::writer_
......@@ -104,9 +92,7 @@ public:
private:
virtual ~Writer();
virtual void SAL_CALL run();
virtual void SAL_CALL onTerminated();
virtual void execute();
void sendRequest(
rtl::ByteSequence const & tid, rtl::OUString const & oid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment