/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCxxPlatform/react/threading/MessageQueueThreadImpl.cpp
38 строк
947 B
Andrew Datsenko
move rncxx threading (#50702)
14 апр 2025, 17:55
14 апр 2025, 17:55
152fa17
Код
Авторство
О чём код?
/* * 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. */ #include "MessageQueueThreadImpl.h" #include <functional> namespace facebook::react { void MessageQueueThreadImpl::runOnQueue(std::function<void()>&& runnable) { if (!taskDispatchThread_.isRunning()) { return; } taskDispatchThread_.runAsync( [runnable = std::move(runnable)]() noexcept { runnable(); }); } void MessageQueueThreadImpl::runOnQueueSync(std::function<void()>&& runnable) { if (!taskDispatchThread_.isRunning()) { return; } if (taskDispatchThread_.isOnThread()) { runnable(); } else { taskDispatchThread_.runSync( [runnable = std::move(runnable)]() noexcept { runnable(); }); } } void MessageQueueThreadImpl::quitSynchronous() { taskDispatchThread_.quit(); } } // namespace facebook::react