summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-07 10:16:02 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-07 17:34:03 +0200
commit7304a1278f50fcc95f7bd31cc137de7292bd55a9 (patch)
treeaf9791db728323ba38dce8ba5090ca376b4877c0
parente15322442b9cc30122349d365a41c7a7bfd83322 (diff)
Added using an own instance of ThreadPool
Using the global ThreadPool (getSharedOptimalPool()) can lead to problems when more than one usage executes and one of them already calls waitUntilEmpty() what of course influences the other usage. Thus I added an own instance of ThreadPool for async loading of chart models in writer Change-Id: I4bea64af0d36e87081abec95c75574966d0fe5b9
-rw-r--r--sw/source/core/ole/ndole.cxx46
1 files changed, 41 insertions, 5 deletions
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index d8b6cec859bf..2538036617c2 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -643,6 +643,38 @@ bool SwOLENode::IsChart() const
}
//////////////////////////////////////////////////////////////////////////////
+// due to some problems in test cases with the SharedOptimalPool, I have to
+// use an own iinstance of comphelper::ThreadPool. Prtoblem is that other
+// usages of getSharedOptimalPool() may interfere when more than one pool
+// user calls waitUntilEmpty().
+//
+// It gets created on-demand and will be available during LO's lifetime for
+// loading chart models used in writer in parallel.
+// It would be possible to add a usage count, then trigger
+// a timer and clean it up (due to lifetime issues), but that's unnecessarily
+// complicated. It gets created on demand, is ready for global reuse and makes
+// no harm (not much ressources needed)
+
+static comphelper::ThreadPool* pLocalPool = 0;
+
+comphelper::ThreadPool* getLocalThreadPool()
+{
+ if (pLocalPool)
+ {
+ return pLocalPool;
+ }
+
+ if (0 == comphelper::ThreadPool::getSharedOptimalPool().getWorkerCount())
+ {
+ return nullptr;
+ }
+
+ pLocalPool = new comphelper::ThreadPool(comphelper::ThreadPool::getSharedOptimalPool().getWorkerCount());
+ return pLocalPool;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// class holding local data for a parellel executed task to load a chart model
class DeflateData
{
@@ -702,6 +734,7 @@ public:
};
//////////////////////////////////////////////////////////////////////////////
+// class defining a parellel executed task to load a chart model
class DeflateThread : public comphelper::ThreadTask
{
@@ -1049,13 +1082,16 @@ drawinglayer::primitive2d::Primitive2DContainer SwOLEObj::tryToGetChartContentAs
if(aXModel.is())
{
- // due to some problems in test cases with the SharedOptimalPool,
- // I need to deactivate this for now
- static bool bAnynchronousLoadingAllowed = false;
+ // added using own instance of comphelper::ThreadPool, see
+ // getLocalThreadPool(). I ran the UnitTests and the problems from
+ // before seem solved, so I optionally allow asynchronous loading
+ // for now. The static bool below is an anchor point to allow
+ // deactivating this feature quickly if trouble surfaces somewhere
+ static bool bAnynchronousLoadingAllowed = true;
if(bSynchron ||
!bAnynchronousLoadingAllowed ||
- 0 == comphelper::ThreadPool::getSharedOptimalPool().getWorkerCount())
+ nullptr == getLocalThreadPool())
{
// load chart synchron in this Thread
m_aPrimitive2DSequence = ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
@@ -1071,7 +1107,7 @@ drawinglayer::primitive2d::Primitive2DContainer SwOLEObj::tryToGetChartContentAs
{
m_pDeflateData = new DeflateData(aXModel);
DeflateThread* pNew = new DeflateThread(*m_pDeflateData);
- comphelper::ThreadPool::getSharedOptimalPool().pushTask(pNew);
+ getLocalThreadPool()->pushTask(pNew);
}
}
}