Skip to content

Commit

Permalink
Make SurfaceManager const correct (facebook#48485)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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
  • Loading branch information
christophpurrer authored and facebook-github-bot committed Jan 6, 2025
1 parent 8681fc2 commit c855251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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);
Expand All @@ -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_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

0 comments on commit c855251

Please sign in to comment.