package/inc/ZipOutputStream.hxx | 6 +++--- package/source/zipapi/ZipOutputStream.cxx | 13 ++++--------- package/source/zippackage/ZipPackageStream.cxx | 9 +++++++-- 3 files changed, 14 insertions(+), 14 deletions(-)
New commits: commit 826e0ee5011152f6009f5eaf4a88b6d57a3efd28 Author: Matúš Kukan <matus.ku...@collabora.com> Date: Tue Nov 4 09:58:00 2014 +0100 package: Use comphelper::ThreadPool for deflating Change-Id: I6bd75c0aeff18b17fba933874a9964fe1dc47404 diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx index 54638d5..acf6dc4 100644 --- a/package/inc/ZipOutputStream.hxx +++ b/package/inc/ZipOutputStream.hxx @@ -23,7 +23,7 @@ #include <com/sun/star/io/XOutputStream.hpp> #include <ByteChucker.hxx> -#include <osl/thread.hxx> +#include <comphelper/threadpool.hxx> #include <vector> @@ -38,7 +38,7 @@ class ZipOutputStream ByteChucker m_aChucker; ZipEntry *m_pCurrentEntry; - std::vector< osl::Thread* > m_aWorkers; + comphelper::ThreadPool &m_rSharedThreadPool; std::vector< ZipOutputEntry* > m_aEntries; public: @@ -46,7 +46,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > &xOStream ); ~ZipOutputStream(); - void addDeflatingThread( ZipOutputEntry *pEntry, osl::Thread *pThread ); + void addDeflatingThread( ZipOutputEntry *pEntry, comphelper::ThreadTask *pThreadTask ); void writeLOC( ZipEntry *pEntry, bool bEncrypt = false ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index c91b351..902816e 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -41,6 +41,7 @@ ZipOutputStream::ZipOutputStream( const uno::Reference < io::XOutputStream > &xO : m_xStream(xOStream) , m_aChucker(xOStream) , m_pCurrentEntry(NULL) +, m_rSharedThreadPool(comphelper::ThreadPool::getSharedOptimalPool()) { } @@ -64,11 +65,10 @@ void ZipOutputStream::setEntry( ZipEntry *pEntry ) } } -void ZipOutputStream::addDeflatingThread( ZipOutputEntry *pEntry, osl::Thread *pThread ) +void ZipOutputStream::addDeflatingThread( ZipOutputEntry *pEntry, comphelper::ThreadTask *pThread ) { - m_aWorkers.push_back(pThread); + m_rSharedThreadPool.pushTask(pThread); m_aEntries.push_back(pEntry); - pThread->create(); } void ZipOutputStream::rawWrite( const Sequence< sal_Int8 >& rBuffer ) @@ -96,12 +96,7 @@ void ZipOutputStream::finish() assert(!m_aZipList.empty() && "Zip file must have at least one entry!"); // Wait for all threads to finish & write - for (size_t i = 0; i < m_aWorkers.size(); i++) - { - m_aWorkers[i]->join(); - delete m_aWorkers[i]; - } - + m_rSharedThreadPool.waitUntilEmpty(); for (size_t i = 0; i < m_aEntries.size(); i++) { writeLOC(m_aEntries[i]->getZipEntry(), m_aEntries[i]->isEncrypt()); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 548f1c5..df0bf46 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -456,7 +456,7 @@ static void deflateZipEntry(ZipOutputEntry *pZipEntry, pZipEntry->closeEntry(); } -class DeflateThread: public osl::Thread +class DeflateThread: public comphelper::ThreadTask { ZipOutputEntry *mpEntry; uno::Reference< io::XInputStream > mxInStream; @@ -469,7 +469,7 @@ public: {} private: - virtual void SAL_CALL run() SAL_OVERRIDE + virtual void doWork() SAL_OVERRIDE { deflateZipEntry(mpEntry, mxInStream); mxInStream.clear(); commit 5916edd1e68af2b2a989c0883c5f39ef17e62a8c Author: Matúš Kukan <matus.ku...@collabora.com> Date: Tue Nov 4 09:18:57 2014 +0100 package: Do not deflate small streams in a thread Change-Id: Iae804a34f344aa793a6d5c13315f7bc1eb64c0a2 diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 1efa9ab..548f1c5 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -798,6 +798,11 @@ bool ZipPackageStream::saveChild( else { bParallelDeflate = true; + // Do not deflate small streams in a thread + uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY ); + if (xSeek.is() && xSeek->getLength() < 100000) + bParallelDeflate = false; + if (bParallelDeflate) { // Start a new thread deflating this zip entry
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits