mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add runtime scheduler priorities
Summary: Changelog: [internal] Add runtime scheduler priorities Reviewed By: JoshuaGross Differential Revision: D27618305 fbshipit-source-id: 95e4e02f3473acb41bca0c22df7b271a8d710f34
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1b0683533a
commit
8d5c22edfd
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "RuntimeSchedulerBinding.h"
|
||||
#include "SchedulerPriority.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -37,8 +38,29 @@ RuntimeSchedulerBinding::createAndInstallIfNeeded(jsi::Runtime &runtime) {
|
||||
jsi::Value RuntimeSchedulerBinding::get(
|
||||
jsi::Runtime &runtime,
|
||||
jsi::PropNameID const &name) {
|
||||
(void)runtime;
|
||||
(void)name;
|
||||
auto propertyName = name.utf8(runtime);
|
||||
|
||||
if (propertyName == "unstable_ImmediatePriority") {
|
||||
return jsi::Value(runtime, serialize(SchedulerPriority::ImmediatePriority));
|
||||
}
|
||||
|
||||
if (propertyName == "unstable_UserBlockingPriority") {
|
||||
return jsi::Value(
|
||||
runtime, serialize(SchedulerPriority::UserBlockingPriority));
|
||||
}
|
||||
|
||||
if (propertyName == "unstable_NormalPriority") {
|
||||
return jsi::Value(runtime, serialize(SchedulerPriority::NormalPriority));
|
||||
}
|
||||
|
||||
if (propertyName == "unstable_LowPriority") {
|
||||
return jsi::Value(runtime, serialize(SchedulerPriority::LowPriority));
|
||||
}
|
||||
|
||||
if (propertyName == "unstable_IdlePriority") {
|
||||
return jsi::Value(runtime, serialize(SchedulerPriority::IdlePriority));
|
||||
}
|
||||
|
||||
return jsi::Value::undefined();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its 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
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
enum class SchedulerPriority : int {
|
||||
ImmediatePriority = 1,
|
||||
UserBlockingPriority = 2,
|
||||
NormalPriority = 3,
|
||||
LowPriority = 4,
|
||||
IdlePriority = 5,
|
||||
};
|
||||
|
||||
static constexpr std::underlying_type<SchedulerPriority>::type serialize(
|
||||
SchedulerPriority schedulerPriority) {
|
||||
return static_cast<std::underlying_type<SchedulerPriority>::type>(
|
||||
schedulerPriority);
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
Reference in New Issue
Block a user