/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCxxPlatform/react/threading/MessageQueueThreadImpl.h
53 строки
2 KB
Eugene Lin
Lower JS Thread Priority by 10
16 апр 2025, 21:19
16 апр 2025, 21:19
d4f2b02
Код
Авторство
О чём код?
/* * 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 <cxxreact/MessageQueueThread.h> #include <react/threading/TaskDispatchThread.h> #include <memory> namespace facebook::react { using MessageQueueThreadFactory = std::function<std::shared_ptr<MessageQueueThread>()>; constexpr char MessageQueueThreadFactoryKey[] = "MessageQueueThreadFactoryKey"; /** * MessageQueueThread implementation that uses a TaskDispatchThread for * queueing and threading logic */ class MessageQueueThreadImpl : public MessageQueueThread { public: MessageQueueThreadImpl() noexcept = default; explicit MessageQueueThreadImpl(int priorityOffset) noexcept : taskDispatchThread_("MessageQueue", priorityOffset) {} ~MessageQueueThreadImpl() noexcept override = default; /** Add a job to the queue asynchronously */ void runOnQueue(std::function<void()>&& runnable) override; /** * Add a job to the queue synchronously - call won't return until runnable * has completed. Will run immediately if called from the looper thread. * Should only be used for initialization. */ void runOnQueueSync(std::function<void()>&& runnable) override; /** * Stop the message queue thread. Should only be used for cleanup - once it * returns, no further work should run on the queue. */ void quitSynchronous() override; private: TaskDispatchThread taskDispatchThread_{"MessageQueue"}; }; } // namespace facebook::react