mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
a8d0dd6646
Summary: Changelog: [internal] Scheduler's callback have option to add more work inside callback. This work stays on top of the priority queue and gives React ability to flush all work synchronously if need. This diff adds use of `shouldYield_` to the workLoop. For now, it always evaluates to false. In the future when we allow access to the scheduler to native, it will allow yielding. Relevant code in JavaScript: https://github.com/facebook/react/blob/master/packages/scheduler/src/forks/SchedulerNoDOM.js#L190 Reviewed By: mdvacca Differential Revision: D27823528 fbshipit-source-id: 016101e41eb7c41c2ac5abb55f803814867b8517
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
/*
|
|
* 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
|
|
|
|
#include <better/optional.h>
|
|
#include <jsi/jsi.h>
|
|
#include <react/renderer/runtimescheduler/RuntimeSchedulerClock.h>
|
|
#include <react/renderer/runtimescheduler/SchedulerPriority.h>
|
|
|
|
namespace facebook::react {
|
|
|
|
class RuntimeScheduler;
|
|
class TaskPriorityComparer;
|
|
|
|
struct Task final {
|
|
Task(
|
|
SchedulerPriority priority,
|
|
jsi::Function callback,
|
|
std::chrono::steady_clock::time_point expirationTime);
|
|
|
|
private:
|
|
friend RuntimeScheduler;
|
|
friend TaskPriorityComparer;
|
|
|
|
SchedulerPriority priority;
|
|
better::optional<jsi::Function> callback;
|
|
RuntimeSchedulerClock::time_point expirationTime;
|
|
|
|
jsi::Value execute(jsi::Runtime &runtime) const;
|
|
};
|
|
|
|
class TaskPriorityComparer {
|
|
public:
|
|
inline bool operator()(
|
|
std::shared_ptr<Task> const &lhs,
|
|
std::shared_ptr<Task> const &rhs) {
|
|
return lhs->expirationTime > rhs->expirationTime;
|
|
}
|
|
};
|
|
|
|
} // namespace facebook::react
|