diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-01-07 00:46:29 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-01-07 00:46:29 +0100 |
commit | 4e6b1987ae73852d0855b6e46e7cd36d8e6989fd (patch) | |
tree | b6116441b0e65f69f0486240875c936ac0e7406b /vespamalloc | |
parent | df9289b224d4730341a8c6c9eceab62c41be360f (diff) |
Simplify the for loop to a while loop since the old value is updated on failure.
Diffstat (limited to 'vespamalloc')
-rw-r--r-- | vespamalloc/src/vespamalloc/malloc/threadproxy.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp b/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp index 7a071e87d41..193215ef83d 100644 --- a/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp +++ b/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp @@ -75,11 +75,11 @@ VESPA_DLL_EXPORT int local_pthread_create (pthread_t *thread, void * (*start_routine) (void *), void * arg) { - size_t numThreads; - for (numThreads = _G_threadCount - ;(numThreads < vespamalloc::_G_myMemP->getMaxNumThreads()) && ! _G_threadCount.compare_exchange_strong(numThreads, numThreads+1) - ; numThreads = _G_threadCount) { - } + size_t numThreads = _G_threadCount; + while ((numThreads < vespamalloc::_G_myMemP->getMaxNumThreads()) + && ! _G_threadCount.compare_exchange_strong(numThreads, numThreads+1)) + { } + if (numThreads >= vespamalloc::_G_myMemP->getMaxNumThreads()) { return EAGAIN; } |