mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Improve performance of setPropertyValue function (#3579)
* Cache full property URIs * Multithreaded handling --------- Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -132,6 +132,9 @@ public:
|
||||
AssetManager& assetManager();
|
||||
LoadingScreen* loadingScreen();
|
||||
|
||||
void invalidatePropertyCache();
|
||||
const std::vector<properties::Property*>& allProperties() const;
|
||||
|
||||
void createUserDirectoriesIfNecessary();
|
||||
|
||||
uint64_t ramInUse() const;
|
||||
@@ -174,6 +177,9 @@ private:
|
||||
|
||||
int _nextCallbackHandle = 0;
|
||||
std::vector<std::pair<CallbackHandle, ModeChangeCallback>> _modeChangeCallbacks;
|
||||
|
||||
mutable bool _isAllPropertiesCacheDirty = true;
|
||||
mutable std::vector<properties::Property*> _allPropertiesCache;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -277,7 +277,7 @@ public:
|
||||
*
|
||||
* \return The fully qualified identifier for this Property
|
||||
*/
|
||||
std::string uri() const;
|
||||
std::string_view uri() const;
|
||||
|
||||
/**
|
||||
* Returns the PropertyOwner of this Property or `nullptr`, if it does not have an
|
||||
@@ -475,6 +475,13 @@ public:
|
||||
*/
|
||||
void resetToUnchanged();
|
||||
|
||||
/**
|
||||
* This function must be called whenever this property's URI changes. Examples of this
|
||||
* are if the PropertyOwner to which this Property belongs changes identifier or is
|
||||
* reparented in any way.
|
||||
*/
|
||||
void updateUriCache();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This method must be called by all subclasses whenever the encapsulated value has
|
||||
@@ -509,6 +516,11 @@ protected:
|
||||
/// The callback functions that will be invoked whenever the value changes
|
||||
std::vector<std::pair<OnDeleteHandle, std::function<void()>>> _onDeleteCallbacks;
|
||||
|
||||
/// A cached version of the full URI of this property, which includes the identifiers
|
||||
/// of all owners
|
||||
std::string _uriCache;
|
||||
bool _isUriCacheDirty = true;
|
||||
|
||||
/// Flag indicating that this property value has been changed after initialization
|
||||
bool _isValueDirty = false;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
* The destructor will remove all Propertys and PropertyOwners it owns along with
|
||||
* itself.
|
||||
*/
|
||||
virtual ~PropertyOwner();
|
||||
virtual ~PropertyOwner() = default;
|
||||
|
||||
/**
|
||||
* Sets the identifier for this PropertyOwner. If the PropertyOwner does not have an
|
||||
@@ -193,8 +193,8 @@ public:
|
||||
*/
|
||||
bool hasProperty(const Property* prop) const;
|
||||
|
||||
void setPropertyOwner(PropertyOwner* owner) { _owner = owner; }
|
||||
PropertyOwner* owner() const { return _owner; }
|
||||
void setPropertyOwner(PropertyOwner* owner);
|
||||
PropertyOwner* owner() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all sub-owners this PropertyOwner has. Each name of a sub-owner
|
||||
@@ -337,6 +337,11 @@ protected:
|
||||
std::map<std::string, std::string> _groupNames;
|
||||
/// Collection of string tag(s) assigned to this property
|
||||
std::vector<std::string> _tags;
|
||||
|
||||
|
||||
private:
|
||||
/// Will regenerate the uri caches for all directly or indirectly owned properties
|
||||
void updateUriCaches();
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
Reference in New Issue
Block a user