Make SurfaceManager const correct (#48485)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48485

[Changelog] [Internal] - Make SurfaceManager const correct

This marks methods which don't modify member props as `const` and others as non `const`.

The current API signature is misleading as `const` methods do alter `mutable` members

Reviewed By: rshest

Differential Revision: D67820439

fbshipit-source-id: 6a991bd7ccbd464c2390e33e0c29b136892d65e0
This commit is contained in:
Christoph Purrer
2025-01-06 14:41:39 -08:00
committed by Facebook GitHub Bot
parent 8681fc2ab2
commit c8552519b3
2 changed files with 7 additions and 7 deletions
@@ -26,7 +26,7 @@ void SurfaceManager::startSurface(
const std::string& moduleName,
const folly::dynamic& props,
const LayoutConstraints& layoutConstraints,
const LayoutContext& layoutContext) const noexcept {
const LayoutContext& layoutContext) noexcept {
{
std::unique_lock lock(mutex_);
auto surfaceHandler = SurfaceHandler{moduleName, surfaceId};
@@ -44,7 +44,7 @@ void SurfaceManager::startSurface(
});
}
void SurfaceManager::stopSurface(SurfaceId surfaceId) const noexcept {
void SurfaceManager::stopSurface(SurfaceId surfaceId) noexcept {
visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
surfaceHandler.stop();
scheduler_.unregisterSurface(surfaceHandler);
@@ -58,7 +58,7 @@ void SurfaceManager::stopSurface(SurfaceId surfaceId) const noexcept {
}
}
void SurfaceManager::stopAllSurfaces() const noexcept {
void SurfaceManager::stopAllSurfaces() noexcept {
std::unordered_set<SurfaceId> surfaceIds;
{
std::shared_lock lock(mutex_);
@@ -36,11 +36,11 @@ class SurfaceManager final {
const std::string& moduleName,
const folly::dynamic& props,
const LayoutConstraints& layoutConstraints = {},
const LayoutContext& layoutContext = {}) const noexcept;
const LayoutContext& layoutContext = {}) noexcept;
void stopSurface(SurfaceId surfaceId) const noexcept;
void stopSurface(SurfaceId surfaceId) noexcept;
void stopAllSurfaces() const noexcept;
void stopAllSurfaces() noexcept;
Size measureSurface(
SurfaceId surfaceId,
@@ -63,7 +63,7 @@ class SurfaceManager final {
const Scheduler& scheduler_;
mutable std::shared_mutex mutex_; // Protects `registry_`.
mutable std::unordered_map<SurfaceId, SurfaceHandler> registry_{};
std::unordered_map<SurfaceId, SurfaceHandler> registry_{};
};
} // namespace facebook::react