From 3c78aa6d256f3e603241ff5f2a80fffecebb00c7 Mon Sep 17 00:00:00 2001 From: DengYun Date: Fri, 17 Jul 2015 09:05:26 -0700 Subject: [PATCH] [Bridge] remove unused semaphore Summary: dispatch_semaphore_wait with DISPATCH_TIME_NOW don't wait for the semaphore. It just test whether there's a signal and return the result. So the line "dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW);" does nothing here. It seems like a bug, but each executing in js thread will be queued, so it's safe to remove the unused semaphore instead of wait for it. Closes https://github.com/facebook/react-native/pull/1915 Github Author: DengYun --- React/Base/RCTBatchedBridge.m | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 138e11695..98fdb5115 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -235,18 +235,13 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL NSString *configJSON = RCTJSONStringify(@{ @"remoteModuleConfig": config, }, NULL); - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [_javaScriptExecutor injectJSONText:configJSON - asGlobalObjectNamed:@"__fbBatchedBridgeConfig" callback: - ^(NSError *error) { - if (error) { - [[RCTRedBox sharedInstance] showError:error]; - } - - dispatch_semaphore_signal(semaphore); - }]; - - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW); + asGlobalObjectNamed:@"__fbBatchedBridgeConfig" + callback:^(NSError *error) { + if (error) { + [[RCTRedBox sharedInstance] showError:error]; + } + }]; NSURL *bundleURL = _parentBridge.bundleURL; if (_javaScriptExecutor == nil) {