File tree Expand file tree Collapse file tree 5 files changed +29
-27
lines changed
Expand file tree Collapse file tree 5 files changed +29
-27
lines changed Original file line number Diff line number Diff line change 3030#import < fabric/uimanager/ContextContainer.h>
3131
3232#import " MainRunLoopEventBeat.h"
33- #import " MessageQueueEventBeat .h"
33+ #import " RuntimeEventBeat .h"
3434#import " RCTConversions.h"
3535
3636using namespace facebook ::react;
@@ -165,12 +165,12 @@ - (RCTScheduler *)_scheduler
165165 });
166166 };
167167
168- EventBeatFactory synchronousBeatFactory = [messageQueueThread ]() {
169- return std::make_unique<MainRunLoopEventBeat>(messageQueueThread );
168+ EventBeatFactory synchronousBeatFactory = [runtimeExecutor ]() {
169+ return std::make_unique<MainRunLoopEventBeat>(runtimeExecutor );
170170 };
171171
172- EventBeatFactory asynchronousBeatFactory = [messageQueueThread ]() {
173- return std::make_unique<MessageQueueEventBeat>(messageQueueThread );
172+ EventBeatFactory asynchronousBeatFactory = [runtimeExecutor ]() {
173+ return std::make_unique<RuntimeEventBeat>(runtimeExecutor );
174174 };
175175
176176 contextContainer->registerInstance <EventBeatFactory>(synchronousBeatFactory, " synchronous" );
Original file line number Diff line number Diff line change 77
88#include < CoreFoundation/CoreFoundation.h>
99#include < CoreFoundation/CFRunLoop.h>
10- #include < cxxreact/MessageQueueThread .h>
10+ #include < fabric/uimanager/FabricUIManager .h>
1111#include < fabric/events/EventBeat.h>
1212
1313namespace facebook {
@@ -21,15 +21,15 @@ class MainRunLoopEventBeat final:
2121 public EventBeat {
2222
2323public:
24- MainRunLoopEventBeat (std::shared_ptr<MessageQueueThread> messageQueueThread );
24+ MainRunLoopEventBeat (RuntimeExecutor runtimeExecutor );
2525 ~MainRunLoopEventBeat ();
2626
2727 void induce () const override ;
2828
2929private:
30- void blockMessageQueueAndThenBeat () const ;
30+ void lockExecutorAndBeat () const ;
3131
32- std::shared_ptr<MessageQueueThread> messageQueueThread_ ;
32+ const RuntimeExecutor runtimeExecutor_ ;
3333 CFRunLoopObserverRef mainRunLoopObserver_;
3434};
3535
Original file line number Diff line number Diff line change 1111namespace facebook {
1212namespace react {
1313
14- MainRunLoopEventBeat::MainRunLoopEventBeat (std::shared_ptr<MessageQueueThread> messageQueueThread ):
15- messageQueueThread_ (std::move(messageQueueThread )) {
14+ MainRunLoopEventBeat::MainRunLoopEventBeat (RuntimeExecutor runtimeExecutor ):
15+ runtimeExecutor_ (std::move(runtimeExecutor )) {
1616
1717 mainRunLoopObserver_ =
1818 CFRunLoopObserverCreateWithHandler (
2525 return ;
2626 }
2727
28- this ->blockMessageQueueAndThenBeat ();
28+ this ->lockExecutorAndBeat ();
2929 }
3030 );
3131
4545 }
4646
4747 RCTExecuteOnMainQueue (^{
48- this ->blockMessageQueueAndThenBeat ();
48+ this ->lockExecutorAndBeat ();
4949 });
5050}
5151
52- void MainRunLoopEventBeat::blockMessageQueueAndThenBeat () const {
52+ void MainRunLoopEventBeat::lockExecutorAndBeat () const {
5353 // Note: We need the third mutex to get back to the main thread before
5454 // the lambda is finished (because all mutexes are allocated on the stack).
5555
6161 mutex2.lock ();
6262 mutex3.lock ();
6363
64- messageQueueThread_-> runOnQueue ([&]() {
64+ runtimeExecutor_ ([&](jsi::Runtime &runtime ) {
6565 mutex1.unlock ();
6666 mutex2.lock ();
6767 mutex3.unlock ();
Original file line number Diff line number Diff line change 77
88#include < CoreFoundation/CoreFoundation.h>
99#include < CoreFoundation/CFRunLoop.h>
10- #include < cxxreact/MessageQueueThread .h>
10+ #include < fabric/uimanager/FabricUIManager .h>
1111#include < fabric/events/EventBeat.h>
1212
1313namespace facebook {
1414namespace react {
1515
1616/*
17- * Event beat that associated with MessageQueueThread.
17+ * Event beat associated with JavaScript runtime.
18+ * The beat is called on `RuntimeExecutor`'s thread induced by the main thread
19+ * event loop.
1820 */
19- class MessageQueueEventBeat :
21+ class RuntimeEventBeat :
2022 public EventBeat {
2123
2224public:
23- MessageQueueEventBeat ( const std::shared_ptr<MessageQueueThread> &messageQueueThread );
24- ~MessageQueueEventBeat ();
25+ RuntimeEventBeat (RuntimeExecutor runtimeExecutor );
26+ ~RuntimeEventBeat ();
2527
2628 void induce () const override ;
2729
2830private:
29- const std::shared_ptr<MessageQueueThread> messageQueueThread_ ;
31+ const RuntimeExecutor runtimeExecutor_ ;
3032 CFRunLoopObserverRef mainRunLoopObserver_;
3133 mutable std::atomic<bool > isBusy_ {false };
3234};
Original file line number Diff line number Diff line change 55 * LICENSE file in the root directory of this source tree.
66 */
77
8- #include " MessageQueueEventBeat .h"
8+ #include " RuntimeEventBeat .h"
99
1010namespace facebook {
1111namespace react {
1212
13- MessageQueueEventBeat::MessageQueueEventBeat ( const std::shared_ptr<MessageQueueThread> &messageQueueThread ):
14- messageQueueThread_ (messageQueueThread ) {
13+ RuntimeEventBeat::RuntimeEventBeat (RuntimeExecutor runtimeExecutor ):
14+ runtimeExecutor_ (std::move(runtimeExecutor) ) {
1515
1616 mainRunLoopObserver_ =
1717 CFRunLoopObserverCreateWithHandler (
3131 CFRunLoopAddObserver (CFRunLoopGetMain (), mainRunLoopObserver_, kCFRunLoopCommonModes );
3232}
3333
34- MessageQueueEventBeat ::~MessageQueueEventBeat () {
34+ RuntimeEventBeat ::~RuntimeEventBeat () {
3535 CFRunLoopRemoveObserver (CFRunLoopGetMain (), mainRunLoopObserver_, kCFRunLoopCommonModes );
3636 CFRelease (mainRunLoopObserver_);
3737}
3838
39- void MessageQueueEventBeat ::induce () const {
39+ void RuntimeEventBeat ::induce () const {
4040 if (!isRequested_ || isBusy_) {
4141 return ;
4242 }
5858#endif
5959
6060 isBusy_ = true ;
61- messageQueueThread_-> runOnQueue ([=]() mutable {
61+ runtimeExecutor_ ([=](jsi::Runtime &runtime ) mutable {
6262 this ->beat ();
6363 isBusy_ = false ;
6464#ifndef NDEBUG
You can’t perform that action at this time.
0 commit comments