mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-06 17:34:07 +08:00
Add copy for surface registry when return enumerator (#24056)
Summary: To ensure all methods in surface registry thread safe, add copy to enumerator method. cc. shergin . [iOS] [Fixed] - Add copy for surface registry when return enumerator Pull Request resolved: https://github.com/facebook/react-native/pull/24056 Differential Revision: D14575446 Pulled By: shergin fbshipit-source-id: 6757f71e251381c4a38d13df4729e9494b3164d1
This commit is contained in:
committed by
Facebook Github Bot
parent
ef512194a6
commit
27e727968a
@@ -26,8 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, strong) RCTComponentViewRegistry *componentViewRegistry;
|
||||
|
||||
/**
|
||||
* Transfroms mutation insturctions to mount items and execute them.
|
||||
* The order of mutation tnstructions matters.
|
||||
* Transfroms mutation instructions to mount items and executes them.
|
||||
* The order of mutation instructions matters.
|
||||
* Can be called from any thread.
|
||||
*/
|
||||
- (void)performTransactionWithMutations:(facebook::react::ShadowViewMutationList)mutations rootTag:(ReactTag)rootTag;
|
||||
|
||||
@@ -283,16 +283,20 @@ using namespace facebook::react;
|
||||
|
||||
- (void)_startAllSurfaces
|
||||
{
|
||||
for (RCTFabricSurface *surface in _surfaceRegistry.enumerator) {
|
||||
[self _startSurface:surface];
|
||||
}
|
||||
[_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RCTFabricSurface *> *enumerator) {
|
||||
for (RCTFabricSurface *surface in enumerator) {
|
||||
[self _startSurface:surface];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)_stopAllSurfaces
|
||||
{
|
||||
for (RCTFabricSurface *surface in _surfaceRegistry.enumerator) {
|
||||
[self _stopSurface:surface];
|
||||
}
|
||||
[_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RCTFabricSurface *> *enumerator) {
|
||||
for (RCTFabricSurface *surface in enumerator) {
|
||||
[self _stopSurface:surface];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - RCTSchedulerDelegate
|
||||
|
||||
@@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class RCTFabricSurface;
|
||||
|
||||
typedef void(^RCTSurfaceEnumeratorBlock)(NSEnumerator<RCTFabricSurface *> *enumerator);
|
||||
|
||||
/**
|
||||
* Registry of Surfaces.
|
||||
* Incapsulates storing Surface objects and quering them by root tag.
|
||||
@@ -21,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@interface RCTSurfaceRegistry : NSObject
|
||||
|
||||
- (NSEnumerator<RCTFabricSurface *> *)enumerator;
|
||||
- (void)enumerateWithBlock:(RCTSurfaceEnumeratorBlock)block;
|
||||
|
||||
/**
|
||||
* Adds Surface object into the registry.
|
||||
|
||||
@@ -26,11 +26,10 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSEnumerator<RCTFabricSurface *> *)enumerator
|
||||
- (void)enumerateWithBlock:(RCTSurfaceEnumeratorBlock)block
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
return [_registry objectEnumerator];
|
||||
block([_registry objectEnumerator]);
|
||||
}
|
||||
|
||||
- (void)registerSurface:(RCTFabricSurface *)surface
|
||||
|
||||
Reference in New Issue
Block a user