diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 18 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.h | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 07dedbead26..2619576b546 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -46,7 +46,10 @@ IceInternal::ThreadPool::unregister(SOCKET fd) void IceInternal::ThreadPool::promoteFollower() { - _threadMutex.unlock(); + if (_multipleThreads) + { + _threadMutex.unlock(); + } } void @@ -97,7 +100,8 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, bool server) : _destroyed(false), _lastFd(INVALID_SOCKET), _handlers(0), - _timeout(0) + _timeout(0), + _multipleThreads(false) { SOCKET fds[2]; createPipe(fds); @@ -125,6 +129,11 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, bool server) : _threadNum = 1; } + if (_threadNum > 1) + { + _multipleThreads = true; + } + try { for (int i = 0 ; i < _threadNum ; ++i) @@ -236,7 +245,10 @@ IceInternal::ThreadPool::run() while (true) { - _threadMutex.lock(); + if (_multipleThreads) + { + _threadMutex.lock(); + } repeatSelect: diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 7effc029dfa..dfdb3aa7d53 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -69,6 +69,7 @@ private: int _handlers; int _timeout; ::IceUtil::Mutex _threadMutex; + bool _multipleThreads; class EventHandlerThread : public ::IceUtil::Thread { |