summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ObjectAdapterI.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-01-25 16:50:20 +0000
committerMark Spruiell <mes@zeroc.com>2007-01-25 16:50:20 +0000
commit2af1be4b75d36ed2022c304c9030ff34162d44db (patch)
tree229182241b85b3dd9b57cf56a02e774b83fcd47a /cpp/src/Ice/ObjectAdapterI.cpp
parentIceGrid file cache fixes (diff)
downloadice-2af1be4b75d36ed2022c304c9030ff34162d44db.tar.bz2
ice-2af1be4b75d36ed2022c304c9030ff34162d44db.tar.xz
ice-2af1be4b75d36ed2022c304c9030ff34162d44db.zip
adding thread-per-connection settings for proxies & OAs
Diffstat (limited to 'cpp/src/Ice/ObjectAdapterI.cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp76
1 files changed, 58 insertions, 18 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 9338f35bd70..1ee53d618e5 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -645,7 +645,7 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
}
}
}
-
+
return false;
}
@@ -717,6 +717,24 @@ Ice::ObjectAdapterI::getServantManager() const
return _servantManager;
}
+bool
+Ice::ObjectAdapterI::getThreadPerConnection() const
+{
+ //
+ // No mutex lock necessary, _threadPerConnection is immutable.
+ //
+ return _threadPerConnection;
+}
+
+size_t
+Ice::ObjectAdapterI::getThreadPerConnectionStackSize() const
+{
+ //
+ // No mutex lock necessary, _threadPerConnectionStackSize is immutable.
+ //
+ return _threadPerConnectionStackSize;
+}
+
Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator,
const ObjectAdapterFactoryPtr& objectAdapterFactory, const string& name,
const string& endpointInfo, const RouterPrx& router, bool noConfig) :
@@ -777,30 +795,52 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
__setNoDelete(true);
try
{
- // First create the per-adapter thread pool, if
- // necessary. This is done before the creation of the incoming
- // connection factory as the thread pool is needed during
- // creation for the call to incFdsInUse.
- if(!_instance->threadPerConnection())
+ _threadPerConnection = properties->getPropertyAsInt(_propertyPrefix + _name + ".ThreadPerConnection") > 0;
+
+ int threadPoolSize = properties->getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.Size");
+ if(threadPoolSize == 0)
+ {
+ threadPoolSize = properties->getPropertyAsInt(_name + ".ThreadPool.Size");
+ }
+ int threadPoolSizeMax = properties->getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.SizeMax");
+ if(threadPoolSizeMax == 0)
+ {
+ threadPoolSizeMax = properties->getPropertyAsInt(_name + ".ThreadPool.SizeMax");
+ }
+
+ if(_threadPerConnection && (threadPoolSize > 0 || threadPoolSizeMax > 0))
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "adapter cannot be configured for both thread pool and thread per connection";
+ throw ex;
+ }
+
+ if(!_threadPerConnection && threadPoolSize == 0 && threadPoolSizeMax == 0)
+ {
+ _threadPerConnection = _instance->threadPerConnection();
+ }
+
+ if(_threadPerConnection)
+ {
+ _threadPerConnectionStackSize =
+ properties->getPropertyAsIntWithDefault(_propertyPrefix + _name + ".ThreadPerConnection.StackSize",
+ _instance->threadPerConnectionStackSize());
+ }
+
+ //
+ // Create the per-adapter thread pool, if necessary. This is done before the creation of the incoming
+ // connection factory as the thread pool is needed during creation for the call to incFdsInUse.
+ //
+ if(threadPoolSize > 0 || threadPoolSizeMax > 0)
{
if(!properties->getProperty(_propertyPrefix + _name + ".ThreadPool.Size").empty() ||
!properties->getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").empty())
{
- int size = properties->getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.Size");
- int sizeMax = properties->getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.SizeMax");
- if(size > 0 || sizeMax > 0)
- {
- _threadPool = new ThreadPool(_instance, _propertyPrefix + _name + ".ThreadPool", 0);
- }
+ _threadPool = new ThreadPool(_instance, _propertyPrefix + _name + ".ThreadPool", 0);
}
else
{
- int size = properties->getPropertyAsInt(_name + ".ThreadPool.Size");
- int sizeMax = properties->getPropertyAsInt(_name + ".ThreadPool.SizeMax");
- if(size > 0 || sizeMax > 0)
- {
- _threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
- }
+ _threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
}
}