diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-06-14 07:19:20 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-06-26 14:01:52 +0200 |
commit | 2c431d257521aab075e5fc398bdc97abcece74c1 (patch) | |
tree | baa3af233d79049516d6e7d4944e108c7257dd95 /package | |
parent | db194a14c92f2f7f8c1903ba4396fd17e721804a (diff) |
tdf#98955 hardware_concurrency not ideal for thread pools
A new static member getPreferredConcurrency added to
comphelper::ThreadPool to return a configurable max
number of threads.
By default the new function returns the hardware_concurrency
value provided by std::thread. When MAX_CONCURRENCY envar is
defined, the return value is limited to whatever is set there.
Three call-sites that used std::thread::hardware_concurrency
have been replaced with getPreferredConcurrency.
Unittests added to cover the functionality of the new member.
Unittests are capped to 4 threads.
Reviewed-on: https://gerrit.libreoffice.org/26254
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit 60e75fb276778459f6055360646d879b8c615d83)
Change-Id: I3332e393a88a5ed436316fa712ed920a4b37f4af
Reviewed-on: https://gerrit.libreoffice.org/26394
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 197c1dacd5725db8ab2faf0aa9b39a2655eb4940)
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index baa288dc9a5d..0ff190a69411 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -832,7 +832,7 @@ bool ZipPackageStream::saveChild( // cores and allow 4-times the amount for having the queue well filled. The // 2nd pparameter is the time to wait beweeen cleanups in 10th of a second. // Both values may be added to the configuration settings if needed. - static sal_Int32 nAllowedThreads(std::max(std::thread::hardware_concurrency(), 1U) * 4); + static sal_Int32 nAllowedThreads(comphelper::ThreadPool::getPreferredConcurrency() * 4); rZipOut.reduceScheduledThreadsToGivenNumberOrLess(nAllowedThreads, 1); // Start a new thread deflating this zip entry |