Files
react-native/ReactCommon/react/renderer/runtimescheduler/Task.h
T
Samuel Susla 0857238633 Pass didUserCallbackTimeout argument to Scheduler's callback
Summary:
changelog: [internal]

RuntimeScheduler's callbacks previously did not pass down argument `didUserCallbackTimeout`. This was intentionally left out because React team intended to remove it. But, as it turns out, it was not removed and it is needed for Offscreen to not enter infinite render loop. In React, it is used here: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberWorkLoop.new.js#L1022-L1028

Reviewed By: ryancat

Differential Revision: D40060377

fbshipit-source-id: c45719fbbd0275ab2bcf9a2bbf0191aaa96010cc
2022-10-05 10:35:33 -07:00

50 lines
1.1 KiB
C++

/*
* 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 <jsi/jsi.h>
#include <react/renderer/runtimescheduler/RuntimeSchedulerClock.h>
#include <react/renderer/runtimescheduler/SchedulerPriority.h>
#include <optional>
namespace facebook {
namespace 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;
std::optional<jsi::Function> callback;
RuntimeSchedulerClock::time_point expirationTime;
jsi::Value execute(jsi::Runtime &runtime, bool didUserCallbackTimeout);
};
class TaskPriorityComparer {
public:
inline bool operator()(
std::shared_ptr<Task> const &lhs,
std::shared_ptr<Task> const &rhs) {
return lhs->expirationTime > rhs->expirationTime;
}
};
} // namespace react
} // namespace facebook