diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-01-31 01:51:15 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-01-31 01:51:15 +0000 |
commit | 4d7448e622a41c5a6e5fd5f05a20118036139fae (patch) | |
tree | 52aa4020efa36cf3b7e63ecbddb41ddc2146f65c /cpp/src/Ice/ThreadPool.cpp | |
parent | Disabled unicode test (diff) | |
download | ice-4d7448e622a41c5a6e5fd5f05a20118036139fae.tar.bz2 ice-4d7448e622a41c5a6e5fd5f05a20118036139fae.tar.xz ice-4d7448e622a41c5a6e5fd5f05a20118036139fae.zip |
Moved isAlive from ThreadControl to Thread
Diffstat (limited to 'cpp/src/Ice/ThreadPool.cpp')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 4ea369ed0b0..7b9f6fbbe8e 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -95,7 +95,8 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p for(int i = 0 ; i < _size ; ++i) { IceUtil::ThreadPtr thread = new EventHandlerThread(this); - _threads.push_back(thread->start(_stackSize)); + thread->start(_stackSize); + _threads.push_back(thread); ++_running; } } @@ -202,7 +203,8 @@ IceInternal::ThreadPool::promoteFollower() try { IceUtil::ThreadPtr thread = new EventHandlerThread(this); - _threads.push_back(thread->start(_stackSize)); + thread->start(_stackSize); + _threads.push_back(thread); ++_running; } catch(const IceUtil::Exception& ex) @@ -225,14 +227,10 @@ IceInternal::ThreadPool::joinWithAllThreads() // threads would never terminate.) // assert(_destroyed); -#if defined(_MSC_VER) && _MSC_VER <= 1200 // The mem_fun_ref below does not work with VC++ 6.0 - for(vector<IceUtil::ThreadControl>::iterator p = _threads.begin(); p != _threads.end(); ++p) + for(vector<IceUtil::ThreadPtr>::iterator p = _threads.begin(); p != _threads.end(); ++p) { - p->join(); + (*p)->getThreadControl().join(); } -#else - for_each(_threads.begin(), _threads.end(), mem_fun_ref(&IceUtil::ThreadControl::join)); -#endif } string @@ -667,16 +665,14 @@ IceInternal::ThreadPool::run() assert(_running <= sz); if(_running < sz) { - vector<IceUtil::ThreadControl>::iterator start = - partition(_threads.begin(), _threads.end(), mem_fun_ref(&IceUtil::ThreadControl::isAlive)); -#if defined(_MSC_VER) && _MSC_VER <= 1200 // The mem_fun_ref below does not work with VC++ 6.0 - for(vector<IceUtil::ThreadControl>::iterator p = start; p != _threads.end(); ++p) + vector<IceUtil::ThreadPtr>::iterator start = + partition(_threads.begin(), _threads.end(), IceUtil::constMemFun(&IceUtil::Thread::isAlive)); + + for(vector<IceUtil::ThreadPtr>::iterator p = start; p != _threads.end(); ++p) { - p->join(); + (*p)->getThreadControl().join(); } -#else - for_each(start, _threads.end(), mem_fun_ref(&IceUtil::ThreadControl::join)); -#endif + _threads.erase(start, _threads.end()); } |