/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.cpp
42 строки
1 KB
Ruslan Shestopalyuk
Pass jsi::Runtime reference into CallInvoker::invoke* callbacks (#43375)
08 мар 2024, 21:28
08 мар 2024, 21:28
76ce789
Код
Авторство
О чём код?
/* * 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 "RuntimeSchedulerCallInvoker.h" #include "RuntimeScheduler.h" #include <utility> namespace facebook::react { RuntimeSchedulerCallInvoker::RuntimeSchedulerCallInvoker( std::weak_ptr<RuntimeScheduler> runtimeScheduler) : runtimeScheduler_(std::move(runtimeScheduler)) {} void RuntimeSchedulerCallInvoker::invokeAsync(CallFunc&& func) noexcept { if (auto runtimeScheduler = runtimeScheduler_.lock()) { runtimeScheduler->scheduleWork( [func = std::move(func)](jsi::Runtime& rt) { func(rt); }); } } void RuntimeSchedulerCallInvoker::invokeSync(CallFunc&& func) { if (auto runtimeScheduler = runtimeScheduler_.lock()) { runtimeScheduler->executeNowOnTheSameThread( [func = std::move(func)](jsi::Runtime& rt) { func(rt); }); } } void RuntimeSchedulerCallInvoker::invokeAsync( SchedulerPriority priority, CallFunc&& func) noexcept { if (auto runtimeScheduler = runtimeScheduler_.lock()) { runtimeScheduler->scheduleTask( priority, [func = std::move(func)](jsi::Runtime& rt) { func(rt); }); } } } // namespace facebook::react