diff options
-rw-r--r-- | cpp/demo/Ice/bidir/CallbackI.cpp | 21 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/CallbackI.h | 32 |
2 files changed, 4 insertions, 49 deletions
diff --git a/cpp/demo/Ice/bidir/CallbackI.cpp b/cpp/demo/Ice/bidir/CallbackI.cpp index 6693ef279a2..52dfb263154 100644 --- a/cpp/demo/Ice/bidir/CallbackI.cpp +++ b/cpp/demo/Ice/bidir/CallbackI.cpp @@ -10,26 +10,18 @@ #include <Ice/Ice.h> #include <CallbackI.h> -#if defined(_MSC_VER) && (_MSC_VER < 1700) -# pragma warning( 4 : 4355 ) // C4355 'this' : used in base member initializer list -#endif - using namespace std; using namespace Ice; using namespace Demo; CallbackSenderI::CallbackSenderI(const Ice::CommunicatorPtr& communicator) : - _communicator(communicator), - _destroy(false), - _callbackSenderThread(new CallbackSenderThread(this)) + _communicator(communicator), _destroy(false) { } void CallbackSenderI::destroy() { - IceUtil::ThreadPtr callbackSenderThread; - { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -37,12 +29,9 @@ CallbackSenderI::destroy() _destroy = true; notify(); - - callbackSenderThread = _callbackSenderThread; - _callbackSenderThread = 0; // Resolve cyclic dependency. } - callbackSenderThread->getThreadControl().join(); + getThreadControl().join(); } void @@ -57,12 +46,6 @@ CallbackSenderI::addClient(const Identity& ident, const Current& current) } void -CallbackSenderI::start() -{ - _callbackSenderThread->start(); -} - -void CallbackSenderI::run() { int num = 0; diff --git a/cpp/demo/Ice/bidir/CallbackI.h b/cpp/demo/Ice/bidir/CallbackI.h index f3fe245c98b..a7c9fe154fa 100644 --- a/cpp/demo/Ice/bidir/CallbackI.h +++ b/cpp/demo/Ice/bidir/CallbackI.h @@ -17,7 +17,7 @@ class CallbackSenderI; typedef IceUtil::Handle<CallbackSenderI> CallbackSenderIPtr; -class CallbackSenderI : public Demo::CallbackSender, public IceUtil::Monitor<IceUtil::Mutex> +class CallbackSenderI : public Demo::CallbackSender, public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> { public: @@ -27,41 +27,13 @@ public: virtual void addClient(const Ice::Identity&, const Ice::Current&); - void start(); - void run(); + virtual void run(); private: Ice::CommunicatorPtr _communicator; bool _destroy; std::set<Demo::CallbackReceiverPrx> _clients; - - // - // We cannot derive CallbackSenderI from IceUtil::Thread, because - // CallbackSenderI uses IceUtil::GCShared as base, and - // IceUtil::Thread uses IceUtil::Shared as base. These two base - // classes are not compatible. Therefore we use this helper class. - // - class CallbackSenderThread : public IceUtil::Thread - { - public: - - CallbackSenderThread(const CallbackSenderIPtr& callbackSender) : - _callbackSender(callbackSender) - { - } - - virtual void run() - { - _callbackSender->run(); - } - - private: - - const CallbackSenderIPtr _callbackSender; - }; - - IceUtil::ThreadPtr _callbackSenderThread; }; #endif |