avoid waiting on the main thread just to send a notification

Reviewed By: nicklockwood

Differential Revision: D3234837

fbshipit-source-id: 587a68df7d08999d4357583ba3160b315bd85239
This commit is contained in:
Marc Horowitz 2016-05-13 17:15:07 -07:00 committed by Facebook Github Bot 8
parent 9e9dfd2ac9
commit 3a2d024514
1 changed files with 11 additions and 0 deletions

View File

@ -124,6 +124,17 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
// `moduleData.instance` to be accessed re-entrantly.
if (_bridge.moduleSetupComplete) {
[self finishSetupForInstance];
} else {
// If we're here, then the module is completely initialized,
// except for what finishSetupForInstance does. When the instance
// method is called after moduleSetupComplete,
// finishSetupForInstance will run. If _requiresMainThreadSetup
// is true, getting the instance will block waiting for the main
// thread, which could take a while if the main thread is busy
// (I've seen 50ms in testing). So we clear that flag, since
// nothing in finishSetupForInstance needs to be run on the main
// thread.
_requiresMainThreadSetup = NO;
}
}