mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
introduce logic for shared native module queue (#41042)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41042 Changelog: [Internal] currently, each native module creates a new module queue if `methodQueue` is not overridden in the native module. we want to see if we can use a single execution queue for a few reasons: - parity with android's queue model - performance: creating so many queues... for what? the overhead of this feels like it exceeds any potential benefit - set us up to remove the assocs from the module to the method queue, which will allow us to deprecate `synthesize methodQueue` and `-(dispatch_queue_t)moduleQueue` API. in this QE, we just start with replacing the KVO assoc'd queue with the shared module queue. Reviewed By: cipolleschi Differential Revision: D50398635 fbshipit-source-id: 0b194a5ae5269e843c7c537a973ee1d345ce1df4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
28d7adea7e
commit
a337fcac5f
+14
-2
@@ -206,6 +206,9 @@ static Class getFallbackClassFromName(const char *name)
|
||||
|
||||
RCTBridgeProxy *_bridgeProxy;
|
||||
RCTBridgeModuleDecorator *_bridgeModuleDecorator;
|
||||
|
||||
BOOL _enableSharedModuleQueue;
|
||||
dispatch_queue_t _sharedModuleQueue;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
@@ -221,6 +224,11 @@ static Class getFallbackClassFromName(const char *name)
|
||||
_bridgeProxy = bridgeProxy;
|
||||
_bridgeModuleDecorator = bridgeModuleDecorator;
|
||||
_invalidating = false;
|
||||
_enableSharedModuleQueue = NO;
|
||||
|
||||
if (_enableSharedModuleQueue) {
|
||||
_sharedModuleQueue = dispatch_queue_create("com.meta.react.turbomodulemanager.queue", DISPATCH_QUEUE_SERIAL);
|
||||
}
|
||||
|
||||
if (RCTTurboModuleInteropEnabled()) {
|
||||
NSMutableDictionary<NSString *, id<RCTBridgeModule>> *legacyInitializedModules = [NSMutableDictionary new];
|
||||
@@ -685,8 +693,12 @@ static Class getFallbackClassFromName(const char *name)
|
||||
* following if condition's block.
|
||||
*/
|
||||
if (!methodQueue) {
|
||||
NSString *methodQueueName = [NSString stringWithFormat:@"com.facebook.react.%sQueue", moduleName];
|
||||
methodQueue = dispatch_queue_create(methodQueueName.UTF8String, DISPATCH_QUEUE_SERIAL);
|
||||
if (_enableSharedModuleQueue) {
|
||||
methodQueue = _sharedModuleQueue;
|
||||
} else {
|
||||
NSString *methodQueueName = [NSString stringWithFormat:@"com.facebook.react.%sQueue", moduleName];
|
||||
methodQueue = dispatch_queue_create(methodQueueName.UTF8String, DISPATCH_QUEUE_SERIAL);
|
||||
}
|
||||
|
||||
if (moduleHasMethodQueueGetter) {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user