Skip to content

Commit 11c09fd

Browse files
committed
Use std::atomic for reliminating races in RCTCxxBridge
1 parent 2eb7bcb commit 11c09fd

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

packages/react-native/React/CxxBridge/RCTCxxBridge.mm

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void onBatchComplete() override
193193

194194
@implementation RCTCxxBridge {
195195
BOOL _didInvalidate;
196-
BOOL _moduleRegistryCreated;
196+
std::atomic<BOOL> _moduleRegistryCreated;
197197

198198
NSMutableArray<RCTPendingCall> *_pendingCalls;
199199
std::atomic<NSInteger> _pendingCount;
@@ -220,12 +220,28 @@ @implementation RCTCxxBridge {
220220
RCTViewRegistry *_viewRegistry_DEPRECATED;
221221
RCTBundleManager *_bundleManager;
222222
RCTCallableJSModules *_callableJSModules;
223+
std::atomic<BOOL> _loading;
224+
std::atomic<BOOL> _valid;
223225
}
224226

225227
@synthesize bridgeDescription = _bridgeDescription;
226-
@synthesize loading = _loading;
227228
@synthesize performanceLogger = _performanceLogger;
228-
@synthesize valid = _valid;
229+
230+
-(BOOL)isLoading {
231+
return _loading;
232+
}
233+
234+
-(void)setLoading:(BOOL)newValue {
235+
_loading = newValue;
236+
}
237+
238+
-(BOOL)isValid {
239+
return _valid;
240+
}
241+
242+
-(void)setValid:(BOOL)newValue {
243+
_valid = newValue;
244+
}
229245

230246
- (RCTModuleRegistry *)moduleRegistry
231247
{

0 commit comments

Comments
 (0)