diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-05-21 12:41:44 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-05-21 17:25:32 +0200 |
commit | aeb2014ba401707dece5d0cf3cb213ce307a5330 (patch) | |
tree | 7d542cbd43ad0a0bbe8b16f2f91808e2abb63d88 /package/source/zippackage/ZipPackageStream.cxx | |
parent | 86618248683fa4048192d15356c7e6b430e8dbb9 (diff) |
remove code confusion about threads vs thread tasks
A threadpool controls a number of threads that execute a number
of thread *tasks* from a queue. The API even says they are tasks.
So it's damn confusing when ZipPackageStream::saveChild()
claims to limit the number of threads to 4x the maximum number
of threads. It limits the number of queued thread tasks.
Change-Id: I317497f27a82d92a7c8566b14aaeae73a4ffef1f
Reviewed-on: https://gerrit.libreoffice.org/72677
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'package/source/zippackage/ZipPackageStream.cxx')
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index db58a2892c33..1d6cd237c8e1 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -448,14 +448,14 @@ static void deflateZipEntry(ZipOutputEntry *pZipEntry, pZipEntry->closeEntry(); } -class DeflateThread: public comphelper::ThreadTask +class DeflateThreadTask: public comphelper::ThreadTask { ZipOutputEntry *mpEntry; uno::Reference< io::XInputStream > mxInStream; public: - DeflateThread( const std::shared_ptr<comphelper::ThreadTaskTag>& pTag, ZipOutputEntry *pEntry, - const uno::Reference< io::XInputStream >& xInStream ) + DeflateThreadTask( const std::shared_ptr<comphelper::ThreadTaskTag>& pTag, ZipOutputEntry *pEntry, + const uno::Reference< io::XInputStream >& xInStream ) : comphelper::ThreadTask(pTag) , mpEntry(pEntry) , mxInStream(xInStream) @@ -826,17 +826,19 @@ bool ZipPackageStream::saveChild( if (bParallelDeflate) { - // tdf#93553 limit to a useful amount of threads. Taking number of available + // tdf#93553 limit to a useful amount of pending tasks. Having way too many + // tasks pending may use a lot of memory. Take number of available // cores and allow 4-times the amount for having the queue well filled. The // 2nd parameter is the time to wait between cleanups in 10th of a second. // Both values may be added to the configuration settings if needed. - static sal_Int32 nAllowedThreads(comphelper::ThreadPool::getPreferredConcurrency() * 4); - rZipOut.reduceScheduledThreadsToGivenNumberOrLess(nAllowedThreads); + static sal_Int32 nAllowedTasks(comphelper::ThreadPool::getPreferredConcurrency() * 4); + rZipOut.reduceScheduledThreadTasksToGivenNumberOrLess(nAllowedTasks); - // Start a new thread deflating this zip entry + // Start a new thread task deflating this zip entry ZipOutputEntry *pZipEntry = new ZipOutputEntry( m_xContext, *pTempEntry, this, bToBeEncrypted); - rZipOut.addDeflatingThread( pZipEntry, std::make_unique<DeflateThread>(rZipOut.getThreadTaskTag(), pZipEntry, xStream) ); + rZipOut.addDeflatingThreadTask( pZipEntry, + std::make_unique<DeflateThreadTask>(rZipOut.getThreadTaskTag(), pZipEntry, xStream) ); } else { |