diff options
Diffstat (limited to 'cpp/src/Ice/Instance.cpp')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 89 |
1 files changed, 57 insertions, 32 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index c5b2b4bff1b..af1b1bc4d67 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -761,6 +761,15 @@ IceInternal::Instance::setLogger(const Ice::LoggerPtr& logger) _initData.logger = logger; } +void +IceInternal::Instance::setThreadHook(const Ice::ThreadNotificationPtr& threadHook) +{ + // + // No locking, as it can only be called during plug-in loading + // + _initData.threadHook = threadHook; +} + IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const InitializationData& initData) : _state(StateActive), _initData(initData), @@ -998,38 +1007,6 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _retryQueue = new RetryQueue(this); - try - { - bool hasPriority = _initData.properties->getProperty("Ice.ThreadPriority") != ""; - int priority = _initData.properties->getPropertyAsInt("Ice.ThreadPriority"); - if(hasPriority) - { - _timer = new IceUtil::Timer(priority); - } - else - { - _timer = new IceUtil::Timer; - } - } - catch(const IceUtil::Exception& ex) - { - Error out(_initData.logger); - out << "cannot create thread for timer:\n" << ex; - throw; - } - - try - { - _endpointHostResolver = new EndpointHostResolver(this); - } - catch(const IceUtil::Exception& ex) - { - Error out(_initData.logger); - out << "cannot create thread for endpoint host resolver:\n" << ex; - throw; - } - - _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0); if(_initData.wstringConverter == 0) { @@ -1114,10 +1091,48 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) // // Load plug-ins. // + assert(!_serverThreadPool); PluginManagerI* pluginManagerImpl = dynamic_cast<PluginManagerI*>(_pluginManager.get()); assert(pluginManagerImpl); pluginManagerImpl->loadPlugins(argc, argv); + + // + // Create threads. + // + try + { + bool hasPriority = _initData.properties->getProperty("Ice.ThreadPriority") != ""; + int priority = _initData.properties->getPropertyAsInt("Ice.ThreadPriority"); + if(hasPriority) + { + _timer = new IceUtil::Timer(priority); + } + else + { + _timer = new IceUtil::Timer; + } + } + catch(const IceUtil::Exception& ex) + { + Error out(_initData.logger); + out << "cannot create thread for timer:\n" << ex; + throw; + } + + try + { + _endpointHostResolver = new EndpointHostResolver(this); + } + catch(const IceUtil::Exception& ex) + { + Error out(_initData.logger); + out << "cannot create thread for endpoint host resolver:\n" << ex; + throw; + } + + _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0); + // // Get default router and locator proxies. Don't move this // initialization before the plug-in initialization!!! The proxies @@ -1195,6 +1210,16 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) // // + // An application can set Ice.InitPlugins=0 if it wants to postpone + // initialization until after it has interacted directly with the + // plug-ins. + // + if(_initData.properties->getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0) + { + pluginManagerImpl->initializePlugins(); + } + + // // This must be done last as this call creates the Ice.Admin object adapter // and eventually register a process proxy with the Ice locator (allowing // remote clients to invoke on Ice.Admin facets as soon as it's registered). |