Skip to content

Commit 7bda0c2

Browse files
rubennortecipolleschi
authored andcommitted
Make queueMicrotask pure virtual (#1337)
Summary: X-link: react/react-native#43311 Pull Request resolved: #1337 Changelog: [internal] We've done this in a separate diff because the changes in Hermes don't propagate immediately to the React Native repository. We need to land the changes in JSI and Hermes first (in a backwards-compatible way) and then land this in a separate commit to make the method mandatory. Reviewed By: neildhar Differential Revision: D54413830 fbshipit-source-id: 3b89fe0e6697b0019544b73daa89d932db97b63a
1 parent 83584f7 commit 7bda0c2

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

API/hermes_abi/HermesABIRuntimeWrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,10 @@ class HermesABIRuntimeWrapper : public Runtime {
710710
return evaluateJavaScript(sjp, sjp->sourceURL());
711711
}
712712

713+
void queueMicrotask(const Function & /*callback*/) override {
714+
THROW_UNIMPLEMENTED();
715+
}
716+
713717
bool drainMicrotasks(int maxMicrotasksHint = -1) override {
714718
return unwrap(vtable_->drain_microtasks(abiRt_, maxMicrotasksHint));
715719
}

API/hermes_sandbox/HermesSandboxRuntime.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,10 @@ class HermesSandboxRuntimeImpl : public facebook::hermes::HermesSandboxRuntime,
17011701
return evaluateJavaScript(sjp, sjp->sourceURL());
17021702
}
17031703

1704+
void queueMicrotask(const Function & /*callback*/) override {
1705+
THROW_UNIMPLEMENTED();
1706+
}
1707+
17041708
bool drainMicrotasks(int maxMicrotasksHint = -1) override {
17051709
SandboxBoolOrError resBoolOrError{
17061710
vt_.drain_microtasks(this, srt_, maxMicrotasksHint)};

API/jsi/jsi/jsi.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ NativeState::~NativeState() {}
8787

8888
Runtime::~Runtime() {}
8989

90-
void Runtime::queueMicrotask(const jsi::Function& /*callback*/) {
91-
throw JSINativeException("queueMicrotask is not implemented in this runtime");
92-
}
93-
9490
Instrumentation& Runtime::instrumentation() {
9591
class NoInstrumentation : public Instrumentation {
9692
std::string getRecordedGCStats() override {

API/jsi/jsi/jsi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class JSI_EXPORT Runtime {
214214
/// its event loop implementation.
215215
///
216216
/// \param callback a function to be executed as a microtask.
217-
virtual void queueMicrotask(const jsi::Function& callback);
217+
virtual void queueMicrotask(const jsi::Function& callback) = 0;
218218

219219
/// Drain the JavaScript VM internal Microtask (a.k.a. Job in ECMA262) queue.
220220
///

0 commit comments

Comments
 (0)