forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add minimal implementation of RuntimeScheduler::scheduleTask
Summary: Changelog: [internal] Add minimal implementation of schedule task. More features and proper scheduling will be added later. Reviewed By: mdvacca Differential Revision: D27622138 fbshipit-source-id: b2e4623d38e7217290a6a3c59ccc10a1c13e3a4f
- Loading branch information
1 parent
71b5178
commit 2779129
Showing
9 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "RuntimeScheduler.h" | ||
|
||
namespace facebook::react { | ||
|
||
Task::Task(SchedulerPriority priority, jsi::Function callback) | ||
: priority_(priority), callback_(std::move(callback)) {} | ||
|
||
SchedulerPriority Task::getPriority() const { | ||
return priority_; | ||
} | ||
|
||
void Task::operator()(jsi::Runtime &runtime) const { | ||
callback_.call(runtime, {}); | ||
} | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 <jsi/jsi.h> | ||
#include <react/renderer/runtimescheduler/SchedulerPriority.h> | ||
|
||
namespace facebook::react { | ||
|
||
class Task final { | ||
public: | ||
Task(SchedulerPriority priority, jsi::Function callback); | ||
|
||
SchedulerPriority priority_; | ||
jsi::Function callback_; | ||
|
||
SchedulerPriority getPriority() const; | ||
|
||
void operator()(jsi::Runtime &runtime) const; | ||
}; | ||
|
||
class TaskPriorityComparer { | ||
public: | ||
inline bool operator()( | ||
std::shared_ptr<Task> const &lhs, | ||
std::shared_ptr<Task> const &rhs) { | ||
return lhs->getPriority() > rhs->getPriority(); | ||
} | ||
}; | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters