/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace formula
{ class FormulaTypedDoubleToken;
}
#define TOKEN_CACHE_SIZE 8
class Color; class ScDocument; struct ScLookupCacheMap; class ScInterpreter;
// SetNumberFormat() is not thread-safe, so calls to it need to be delayed to the main thread. struct DelayedSetNumberFormat
{
SCCOL mCol;
SCROW mRow;
sal_uInt32 mnNumberFormat;
};
struct ScInterpreterContext
{ const ScDocument* mpDoc;
size_t mnTokenCachePos;
std::vector<formula::FormulaTypedDoubleToken*> maTokens;
std::vector<DelayedSetNumberFormat> maDelayedSetNumberFormat;
std::unique_ptr<ScLookupCacheMap> mxScLookupCache; // cache for lookups like VLOOKUP and MATCH // Allocation cache for "aConditions" array in ScInterpreter::IterateParameterIfs() // This is populated/used only when formula-group threading is enabled.
std::vector<sal_uInt8> maConditions;
std::mt19937 aRNG;
ScInterpreter* pInterpreter;
// During threaded calculation, where we don't need to add to the number // format data, we can access the numbering data with a RO unlocked view of // the NumberFormat's data and a throw-away object for currently used language // This is essentially an exploded view of mpFormatter
std::unique_ptr<SvNFLanguageData> mxLanguageData; // FormatData can be driven read-only, but may want to cache some data, // in RO Mode we can cache per thread to mxAuxFormatKeyMap, and // discard or merge after threaded calculation is over
std::unique_ptr<SvNFFormatData::DefaultFormatKeysMap> mxAuxFormatKeyMap;
// Some temp caches of the 4 most recent results from NumberFormatting // lookups. struct NFBuiltIn
{
sal_uInt64 nKey;
sal_uInt32 nFormat;
NFBuiltIn()
: nKey(SAL_MAX_UINT64)
, nFormat(SAL_MAX_UINT32)
{
}
}; // from format+lang to builtin format mutable std::array<NFBuiltIn, 4> maNFBuiltInCache; struct NFType
{
sal_uInt32 nKey;
SvNumFormatType eType;
NFType()
: nKey(SAL_MAX_UINT32)
, eType(SvNumFormatType::ALL)
{
}
}; // from format index to type mutable std::array<NFType, 4> maNFTypeCache;
// Formatter used when non-nthreaded calculation
SvNumberFormatter* mpFormatter;
};
class ScInterpreterContextPool
{ friendclass ScThreadedInterpreterContextGetterGuard; friendclass ScInterpreterContextGetterGuard;
// Ensures nNumThreads elements in pool. void Init(size_t nNumThreads, const ScDocument& rDoc, SvNumberFormatter* pFormatter);
// Returns ScInterpreterContext* for thread index nThreadIdx
ScInterpreterContext* GetInterpreterContextForThreadIdx(size_t nThreadIdx) const;
// API for non-threaded
// Ensures there is one unused element in the pool. void Init(const ScDocument& rDoc, SvNumberFormatter* pFormatter);
// Returns ScInterpreterContext* for non-threaded use.
ScInterpreterContext* GetInterpreterContext() const;
// Common API for threaded/non-threaded
// Cleans up the contexts prepared by call to immediately previous Init() and // marks them all as unused. void ReturnToPool();
public: // Only to be used to clear lookup cache in all pool elements staticvoid ClearLookupCaches(const ScDocument* pDoc); // Called from ScModule dtor, drop all resources staticvoid ModuleExiting();
};
class ScThreadedInterpreterContextGetterGuard
{
ScInterpreterContextPool& rPool;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.