Skip to content

Commit

Permalink
Use std::atomic for reliminating races in RCTCxxBridge
Browse files Browse the repository at this point in the history
  • Loading branch information
hakonk committed Jul 20, 2024
1 parent 2eb7bcb commit 11c09fd
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/react-native/React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void onBatchComplete() override

@implementation RCTCxxBridge {
BOOL _didInvalidate;
BOOL _moduleRegistryCreated;
std::atomic<BOOL> _moduleRegistryCreated;

NSMutableArray<RCTPendingCall> *_pendingCalls;
std::atomic<NSInteger> _pendingCount;
Expand All @@ -220,12 +220,28 @@ @implementation RCTCxxBridge {
RCTViewRegistry *_viewRegistry_DEPRECATED;
RCTBundleManager *_bundleManager;
RCTCallableJSModules *_callableJSModules;
std::atomic<BOOL> _loading;
std::atomic<BOOL> _valid;
}

@synthesize bridgeDescription = _bridgeDescription;
@synthesize loading = _loading;
@synthesize performanceLogger = _performanceLogger;
@synthesize valid = _valid;

-(BOOL)isLoading {
return _loading;
}

-(void)setLoading:(BOOL)newValue {
_loading = newValue;
}

-(BOOL)isValid {
return _valid;
}

-(void)setValid:(BOOL)newValue {
_valid = newValue;
}

- (RCTModuleRegistry *)moduleRegistry
{
Expand Down

0 comments on commit 11c09fd

Please sign in to comment.