/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCommon/react/renderer/consistency/ScopedShadowTreeRevisionLock.h
54 строки
1 KB
Rubén Norte
Implement UI consistency mechanism for JS thread (#43581)
25 мар 2024, 19:50
25 мар 2024, 19:50
332355e
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <react/renderer/consistency/ShadowTreeRevisionConsistencyManager.h> namespace facebook::react { /** * This is a RAII class that locks the shadow tree revisions during its * lifetime. * * @example * { * ScopedShadowTreeRevisionLock lock(consistencyManager); * runJavaScriptTask(); // During this execution, the lock will be active. * } */ class ScopedShadowTreeRevisionLock { public: explicit ScopedShadowTreeRevisionLock( ShadowTreeRevisionConsistencyManager* consistencyManager) noexcept : consistencyManager_(consistencyManager) { if (consistencyManager_ != nullptr) { consistencyManager_->lockRevisions(); } } // Non-movable ScopedShadowTreeRevisionLock(const ScopedShadowTreeRevisionLock&) = delete; ScopedShadowTreeRevisionLock(ScopedShadowTreeRevisionLock&&) = delete; // Non-copyable ScopedShadowTreeRevisionLock& operator=(const ScopedShadowTreeRevisionLock&) = delete; ScopedShadowTreeRevisionLock& operator=(ScopedShadowTreeRevisionLock&&) = delete; ~ScopedShadowTreeRevisionLock() noexcept { if (consistencyManager_ != nullptr) { consistencyManager_->unlockRevisions(); } } private: ShadowTreeRevisionConsistencyManager* consistencyManager_; }; } // namespace facebook::react