summaryrefslogtreecommitdiff
path: root/vcl/source/bitmap
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-07-08 14:29:53 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-07-18 06:49:09 +0000
commit76ad32bec8e2c00c21247041b16d9e09e73d2504 (patch)
tree7b2b1277151bc7904ff63684ebd7e3d6d8a7d661 /vcl/source/bitmap
parent9bf9f88e4c7e0b182ec6d8b4aefb7d735bb0653b (diff)
add tagging to ThreadTasks so we don't need more one pool
If more than one place in the code submits tasks to the shared pool, then waitTillDone() becomes unreliable. Add a tagging mechanism, so different callsites can wait on different sets of tasks. Also try to protect our worker threads against exceptions from the thread tasks code. Change-Id: Idde664ab50008d31a2dd73910bb22f50e62ae22f Reviewed-on: https://gerrit.libreoffice.org/27042 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl/source/bitmap')
-rw-r--r--vcl/source/bitmap/bitmapscalesuper.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx
index 9fb1f44a0f9c..ff01aaebdab5 100644
--- a/vcl/source/bitmap/bitmapscalesuper.cxx
+++ b/vcl/source/bitmap/bitmapscalesuper.cxx
@@ -89,7 +89,8 @@ class ScaleTask : public comphelper::ThreadTask
ScaleRangeFn mpFn;
std::vector< ScaleRangeContext > maStrips;
public:
- explicit ScaleTask( ScaleRangeFn pFn ) : mpFn( pFn ) {}
+ explicit ScaleTask( const std::shared_ptr<comphelper::ThreadTaskTag>& pTag, ScaleRangeFn pFn )
+ : comphelper::ThreadTask(pTag), mpFn( pFn ) {}
void push( ScaleRangeContext &aRC ) { maStrips.push_back( aRC ); }
virtual void doWork() override
{
@@ -1000,6 +1001,7 @@ bool BitmapScaleSuper::filter(Bitmap& rBitmap)
{
// partition and queue work
comphelper::ThreadPool &rShared = comphelper::ThreadPool::getSharedOptimalPool();
+ std::shared_ptr<comphelper::ThreadTaskTag> pTag = comphelper::ThreadPool::createThreadTaskTag();
sal_uInt32 nThreads = rShared.getWorkerCount();
assert( nThreads > 0 );
sal_uInt32 nStrips = ((nEndY - nStartY) + SCALE_THREAD_STRIP - 1) / SCALE_THREAD_STRIP;
@@ -1008,7 +1010,7 @@ bool BitmapScaleSuper::filter(Bitmap& rBitmap)
long nStripY = nStartY;
for ( sal_uInt32 t = 0; t < nThreads - 1; t++ )
{
- ScaleTask *pTask = new ScaleTask( pScaleRangeFn );
+ ScaleTask *pTask = new ScaleTask( pTag, pScaleRangeFn );
for ( sal_uInt32 j = 0; j < nStripsPerThread; j++ )
{
ScaleRangeContext aRC( &aContext, nStripY );
@@ -1020,7 +1022,7 @@ bool BitmapScaleSuper::filter(Bitmap& rBitmap)
// finish any remaining bits here
pScaleRangeFn( aContext, nStripY, nEndY );
- rShared.waitUntilEmpty();
+ rShared.waitUntilDone(pTag);
SAL_INFO("vcl.gdi", "All threaded scaling tasks complete");
}