summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Instance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/Instance.cpp')
-rw-r--r--cpp/src/Ice/Instance.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index ef5a4b2f167..9349990bb63 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -18,6 +18,7 @@
#include <Ice/ReferenceFactory.h>
#include <Ice/ProxyFactory.h>
#include <Ice/ThreadPool.h>
+#include <Ice/SelectorThread.h>
#include <Ice/ConnectionFactory.h>
#include <Ice/ConnectionMonitor.h>
#include <Ice/ObjectFactoryManager.h>
@@ -235,6 +236,42 @@ IceInternal::Instance::serverThreadPool()
return _serverThreadPool;
}
+SelectorThreadPtr
+IceInternal::Instance::selectorThread()
+{
+ IceUtil::RecMutex::Lock sync(*this);
+
+ if(_state == StateDestroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ if(!_selectorThread) // Lazy initialization.
+ {
+ _selectorThread = new SelectorThread(this);
+ }
+
+ return _selectorThread;
+}
+
+EndpointHostResolverPtr
+IceInternal::Instance::endpointHostResolver()
+{
+ IceUtil::RecMutex::Lock sync(*this);
+
+ if(_state == StateDestroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ if(!_endpointHostResolver) // Lazy initialization.
+ {
+ _endpointHostResolver = new EndpointHostResolver(this);
+ }
+
+ return _endpointHostResolver;
+}
+
IceUtil::TimerPtr
IceInternal::Instance::timer()
{
@@ -914,6 +951,8 @@ IceInternal::Instance::~Instance()
assert(!_objectAdapterFactory);
assert(!_clientThreadPool);
assert(!_serverThreadPool);
+ assert(!_selectorThread);
+ assert(!_endpointHostResolver);
assert(!_timer);
assert(!_routerManager);
assert(!_locatorManager);
@@ -1077,6 +1116,8 @@ IceInternal::Instance::destroy()
ThreadPoolPtr serverThreadPool;
ThreadPoolPtr clientThreadPool;
+ SelectorThreadPtr selectorThread;
+ EndpointHostResolverPtr endpointHostResolver;
{
IceUtil::RecMutex::Lock sync(*this);
@@ -1102,6 +1143,18 @@ IceInternal::Instance::destroy()
std::swap(_clientThreadPool, clientThreadPool);
}
+ if(_selectorThread)
+ {
+ _selectorThread->destroy();
+ std::swap(selectorThread, _selectorThread);
+ }
+
+ if(_endpointHostResolver)
+ {
+ _endpointHostResolver->destroy();
+ std::swap(endpointHostResolver, _endpointHostResolver);
+ }
+
if(_timer)
{
_timer->destroy();
@@ -1169,6 +1222,14 @@ IceInternal::Instance::destroy()
{
serverThreadPool->joinWithAllThreads();
}
+ if(selectorThread)
+ {
+ selectorThread->joinWithThread();
+ }
+ if(endpointHostResolver)
+ {
+ endpointHostResolver->getThreadControl().join();
+ }
if(_initData.properties->getPropertyAsInt("Ice.Warn.UnusedProperties") > 0)
{