Skip to content

Commit

Permalink
Fabric: Using EventBeat::Owner to prevent a crash caused by issuing a…
Browse files Browse the repository at this point in the history
… bit for already deallocated Scheduler

Summary:
The concept of `EventBeat::Owner` was introduced in D17128549, this diff implements some missing pieces of that.

After the change, AsyncEventEmitter will check the existence of the "owner" (which is EventDispatcher) which guarantees that the rest of the pipeline is still alive (the validity of Runtime is guaranteed by RuntimeExecutor separately).

The overall workflow is described in D17128549.

Reviewed By: JoshuaGross

Differential Revision: D17410738

fbshipit-source-id: a1ae8e09600546874cdc7c622b3d884b71c5b48d
  • Loading branch information
shergin authored and facebook-github-bot committed Sep 17, 2019
1 parent e98a4b5 commit 46120bc
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class AsyncEventBeat : public EventBeat {
}

void induce() const override {
runtimeExecutor_([=](jsi::Runtime &runtime) {
runtimeExecutor_([this, ownerBox = ownerBox_](jsi::Runtime &runtime) {
auto owner = ownerBox->owner.lock();
if (!owner) {
return;
}

this->beat(runtime);
});
}
Expand Down

0 comments on commit 46120bc

Please sign in to comment.