sc/inc/document.hxx | 17 ++++------------- sc/source/core/data/documen8.cxx | 7 ++----- sc/source/core/data/document.cxx | 22 +++------------------- sc/source/core/data/formulacell.cxx | 5 ++--- 4 files changed, 11 insertions(+), 40 deletions(-)
New commits: commit f98af92e2bbc2064ddc18b80ede68f4267813ddf Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Fri Nov 27 11:43:10 2020 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Nov 30 13:17:44 2020 +0100 clean up ScDocumentThreadSpecific IIRC there has always been a bit of an overlap between ScDocumentThreadSpecific and ScInterpreterContext, but it has evolved over time into the current state, which AFAICT is that ScDocumentThreadSpecific is just a thread_local aggregate of thread-specific data (including ScInterpreterContext) and ScInterpreterContext is the actual storage used for passing data around (including to/from the worker threads). So remove obsolete parts of ScDocumentThreadSpecific, including the functions for moving data to/from threads (they do not do anything, they even can't do anything because the struct is thread_local, and they have already been incorrectly converted to static by loplugin). Change-Id: I81fff7c83df151413a5387b3173af60f122f374a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106759 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 44c1fc6fd4b4..1dd00f732cbf 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -297,16 +297,7 @@ const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() struct ScDocumentThreadSpecific { std::unique_ptr<ScRecursionHelper> xRecursionHelper; // information for recursive and iterative cell formulas - ScInterpreterContext* pContext; // references the context passed around for easier access - - ScDocumentThreadSpecific(); - ~ScDocumentThreadSpecific(); - - // To be called in the thread at start - static void SetupFromNonThreadedData(const ScDocumentThreadSpecific& rNonThreadedData); - - // To be called in the main thread after the thread has finished - static void MergeBackIntoNonThreadedData(ScDocumentThreadSpecific& rNonThreadedData); + ScInterpreterContext* pContext = nullptr; // references the context passed around for easier access }; /// Enumeration to determine which pieces of the code should not be mutated when set. @@ -619,8 +610,8 @@ public: { return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext(); } - static void SetupFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber ); - void MergeBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber ); + void SetupContextFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber ); + void MergeContextBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber ); void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; } bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; } @@ -2192,7 +2183,7 @@ public: */ void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen ); - const ScDocumentThreadSpecific& CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal); + void CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal); void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter ); /** diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index dbedc986f93c..5c72e9d6198b 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -407,16 +407,15 @@ void ScDocument::SetFormulaResults( const ScAddress& rTopPos, const double* pRes pTab->SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen); } -const ScDocumentThreadSpecific& ScDocument::CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal) +void ScDocument::CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal) { ScTable* pTab = FetchTable(rCalcRange.aStart.Tab()); if (!pTab) - return maNonThreaded; + return; assert(IsThreadedGroupCalcInProgress()); maThreadSpecific.pContext = &rContext; - ScDocumentThreadSpecific::SetupFromNonThreadedData(maNonThreaded); pTab->CalculateInColumnInThread(rContext, rCalcRange.aStart.Col(), rCalcRange.aEnd.Col(), rCalcRange.aStart.Row(), rCalcRange.aEnd.Row(), nThisThread, nThreadsTotal); assert(IsThreadedGroupCalcInProgress()); @@ -425,8 +424,6 @@ const ScDocumentThreadSpecific& ScDocument::CalculateInColumnInThread( ScInterpr // (and e.g. outlive the ScDocument), clean them up here, they cannot be cleaned up // later from the main thread. maThreadSpecific.xRecursionHelper->Clear(); - - return maThreadSpecific; } void ScDocument::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter ) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 8e906940b90b..cb3212ece075 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6812,29 +6812,13 @@ ScRecursionHelper& ScDocument::GetRecursionHelper() } } -void ScDocumentThreadSpecific::SetupFromNonThreadedData(const ScDocumentThreadSpecific& /*rNonThreadedData*/) -{ - // What about the recursion helper? - // Copy the lookup cache? -} - -void ScDocumentThreadSpecific::MergeBackIntoNonThreadedData(ScDocumentThreadSpecific& /*rNonThreadedData*/) -{ - // What about recursion helper and lookup cache? -} - -ScDocumentThreadSpecific::ScDocumentThreadSpecific() - : pContext(nullptr) -{} - -ScDocumentThreadSpecific::~ScDocumentThreadSpecific() {} - -void ScDocument::SetupFromNonThreadedContext(ScInterpreterContext& /*threadedContext*/, int /*threadNumber*/) +void ScDocument::SetupContextFromNonThreadedContext(ScInterpreterContext& /*threadedContext*/, int /*threadNumber*/) { + (void)this; // lookup cache is now only in pooled ScInterpreterContext's } -void ScDocument::MergeBackIntoNonThreadedContext(ScInterpreterContext& threadedContext, int /*threadNumber*/) +void ScDocument::MergeContextBackIntoNonThreadedContext(ScInterpreterContext& threadedContext, int /*threadNumber*/) { // Move data from a context used by a calculation thread to the main thread's context. // Called from the main thread after the calculation thread has already finished. diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 1d789e04b1bc..0ba55750e57b 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -4864,7 +4864,6 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope ScRange aCalcRange(mnStartCol, mrTopPos.Row() + mnStartOffset, mrTopPos.Tab(), mnEndCol, mrTopPos.Row() + mnEndOffset, mrTopPos.Tab()); mpDocument->CalculateInColumnInThread(*mpContext, aCalcRange, mnThisThread, mnThreadsTotal); - ScDocumentThreadSpecific::MergeBackIntoNonThreadedData(mpDocument->maNonThreaded); } }; @@ -4927,7 +4926,7 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope assert(!context->pInterpreter); aInterpreters[i].reset(new ScInterpreter(this, rDocument, *context, mxGroup->mpTopCell->aPos, *pCode, true)); context->pInterpreter = aInterpreters[i].get(); - ScDocument::SetupFromNonThreadedContext(*context, i); + rDocument.SetupContextFromNonThreadedContext(*context, i); rThreadPool.pushTask(std::make_unique<Executor>(aTag, i, nThreadCount, &rDocument, context, mxGroup->mpTopCell->aPos, nColStart, nColEnd, nStartOffset, nEndOffset)); } @@ -4943,7 +4942,7 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope { context = aContextGetterGuard.GetInterpreterContextForThreadIdx(i); // This is intentionally done in this main thread in order to avoid locking. - rDocument.MergeBackIntoNonThreadedContext(*context, i); + rDocument.MergeContextBackIntoNonThreadedContext(*context, i); context->pInterpreter = nullptr; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits