Skip to content

Commit

Permalink
Pass RuntimeExecutor into RCTSurfacePresenter
Browse files Browse the repository at this point in the history
Summary: Instead of getting `RuntimeExecutor` from the bridge, pass it from above. Right now pass through `null`, but eventually this will work :)

Reviewed By: RSNara

Differential Revision: D16626288

fbshipit-source-id: bce527f85c0a79cfe6cf240a3633bbbe357f75c4
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Aug 15, 2019
1 parent a380f0f commit 0b3aeec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion RNTester/RNTester/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith
config:nil
imageLoader:RCTTurboModuleEnabled() ?
[_bridge moduleForName:@"RCTImageLoader"
lazilyLoadIfNecessary:YES] : nil];
lazilyLoadIfNecessary:YES] : nil
runtimeExecutor:nullptr];

_bridge.surfacePresenter = _surfacePresenter;

Expand Down
4 changes: 3 additions & 1 deletion React/Fabric/RCTSurfacePresenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import <React/RCTSurfacePresenterStub.h>
#import <react/config/ReactNativeConfig.h>
#import <react/utils/ContextContainer.h>
#import <react/utils/RuntimeExecutor.h>

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -31,7 +32,8 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)initWithBridge:(RCTBridge *)bridge
config:(std::shared_ptr<const facebook::react::ReactNativeConfig>)config
imageLoader:(RCTImageLoader *)imageLoader;
imageLoader:(RCTImageLoader *)imageLoader
runtimeExecutor:(facebook::react::RuntimeExecutor)runtimeExecutor;

@property (nonatomic, readonly) RCTComponentViewFactory *componentViewFactory;
@property (nonatomic, readonly) facebook::react::ContextContainer::Shared contextContainer;
Expand Down
12 changes: 9 additions & 3 deletions React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#import <react/uimanager/SchedulerToolbox.h>
#import <react/utils/ContextContainer.h>
#import <react/utils/ManagedObjectWrapper.h>
#import <react/utils/RuntimeExecutor.h>

#import "MainRunLoopEventBeat.h"
#import "RCTConversions.h"
Expand Down Expand Up @@ -63,14 +62,17 @@ @implementation RCTSurfacePresenter {
better::shared_mutex _observerListMutex;
NSMutableArray<id<RCTSurfacePresenterObserver>> *_observers;
RCTImageLoader *_imageLoader;
RuntimeExecutor _runtimeExecutor;
}

- (instancetype)initWithBridge:(RCTBridge *)bridge
config:(std::shared_ptr<const ReactNativeConfig>)config
imageLoader:(RCTImageLoader *)imageLoader
runtimeExecutor:(RuntimeExecutor)runtimeExecutor
{
if (self = [super init]) {
_imageLoader = imageLoader;
_runtimeExecutor = runtimeExecutor;
_bridge = bridge;
_batchedBridge = [_bridge batchedBridge] ?: _bridge;
[_batchedBridge setSurfacePresenter:self];
Expand Down Expand Up @@ -199,7 +201,7 @@ - (RCTScheduler *)_scheduler
createComponentDescriptorRegistryWithParameters:{eventDispatcher, contextContainer}];
};

auto runtimeExecutor = [self _runtimeExecutor];
auto runtimeExecutor = [self getRuntimeExecutor];

auto toolbox = SchedulerToolbox{};
toolbox.contextContainer = self.contextContainer;
Expand All @@ -222,8 +224,12 @@ - (RCTScheduler *)_scheduler

@synthesize contextContainer = _contextContainer;

- (RuntimeExecutor)_runtimeExecutor
- (RuntimeExecutor)getRuntimeExecutor
{
if (_runtimeExecutor) {
return _runtimeExecutor;
}

auto messageQueueThread = _batchedBridge.jsMessageThread;
if (messageQueueThread) {
// Make sure initializeBridge completed
Expand Down

0 comments on commit 0b3aeec

Please sign in to comment.