diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-06-01 15:31:11 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-06-01 15:31:11 +0000 |
commit | dba48e6aa9feac17c9ee2c02adb90a01c9ebae8e (patch) | |
tree | 1f890a3a36238d21c10bb7adba0dc979c2905689 /cpp | |
parent | Added a bunch of missing dependencies on Glacier2 to a few IceGrid (diff) | |
download | ice-dba48e6aa9feac17c9ee2c02adb90a01c9ebae8e.tar.bz2 ice-dba48e6aa9feac17c9ee2c02adb90a01c9ebae8e.tar.xz ice-dba48e6aa9feac17c9ee2c02adb90a01c9ebae8e.zip |
Added thread start/stop hooks
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/Initialize.h | 18 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 10 |
3 files changed, 38 insertions, 0 deletions
diff --git a/cpp/include/Ice/Initialize.h b/cpp/include/Ice/Initialize.h index 824d3f5f985..3d7e166072c 100644 --- a/cpp/include/Ice/Initialize.h +++ b/cpp/include/Ice/Initialize.h @@ -37,6 +37,23 @@ ICE_API PropertiesPtr createProperties(); ICE_API PropertiesPtr createProperties(StringSeq&); ICE_API PropertiesPtr createProperties(int&, char*[]); +// +// This class is used to notify user of when Ice threads +// are started and stopped. +// +class ThreadNotification : public IceUtil::Shared +{ +public: + + virtual void start() = 0; + virtual void stop() = 0; +}; + +typedef IceUtil::Handle<ThreadNotification> ThreadNotificationPtr; + +// +// Communicator initialization info +// struct InitializationData { PropertiesPtr properties; @@ -45,6 +62,7 @@ struct InitializationData Context defaultContext; StringConverterPtr stringConverter; WstringConverterPtr wstringConverter; + ThreadNotificationPtr threadHook; }; ICE_API CommunicatorPtr initialize(int&, char*[], InitializationData = InitializationData(), diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index b23e628466d..2a5ca75f12e 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -2572,6 +2572,11 @@ Ice::ConnectionI::ThreadPerConnection::ThreadPerConnection(const ConnectionIPtr& void Ice::ConnectionI::ThreadPerConnection::run() { + if(_connection->_instance->initializationData().threadHook) + { + _connection->_instance->initializationData().threadHook->start(); + } + try { _connection->run(); @@ -2592,5 +2597,10 @@ Ice::ConnectionI::ThreadPerConnection::run() out << "unknown exception in thread per connection:\n" << _connection->toString(); } + if(_connection->_instance->initializationData().threadHook) + { + _connection->_instance->initializationData().threadHook->stop(); + } + _connection = 0; // Resolve cyclic dependency. } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 4d291161fbd..0bb280f8037 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -851,6 +851,11 @@ IceInternal::ThreadPool::EventHandlerThread::EventHandlerThread(const ThreadPool void IceInternal::ThreadPool::EventHandlerThread::run() { + if(_pool->_instance->initializationData().threadHook) + { + _pool->_instance->initializationData().threadHook->start(); + } + bool promote; try @@ -890,5 +895,10 @@ IceInternal::ThreadPool::EventHandlerThread::run() } } + if(_pool->_instance->initializationData().threadHook) + { + _pool->_instance->initializationData().threadHook->stop(); + } + _pool = 0; // Break cyclic dependency. } |