diff options
Diffstat (limited to 'cpp/src/Ice/ThreadPool.cpp')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 18 |
1 files changed, 15 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: |