Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios] Remove dispatch_once_t used as a member instance #7576

Merged
merged 5 commits into from Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,7 +18,6 @@
@interface ABI34_0_0UMExportedModule ()

@property (nonatomic, strong) dispatch_queue_t methodQueue;
@property (nonatomic, assign) dispatch_once_t methodQueueSetupOnce;
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *exportedMethods;

@end
Expand Down Expand Up @@ -55,14 +54,10 @@ - (NSDictionary *)constantsToExport

- (dispatch_queue_t)methodQueue
{
__weak ABI34_0_0UMExportedModule *weakSelf = self;
dispatch_once(&_methodQueueSetupOnce, ^{
__strong ABI34_0_0UMExportedModule *strongSelf = weakSelf;
if (strongSelf) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[strongSelf class] exportedModuleName]];
strongSelf.methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
});
if (!_methodQueue) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[self class] exportedModuleName]];
_methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
return _methodQueue;
}

Expand Down
Expand Up @@ -18,7 +18,6 @@
@interface ABI35_0_0UMExportedModule ()

@property (nonatomic, strong) dispatch_queue_t methodQueue;
@property (nonatomic, assign) dispatch_once_t methodQueueSetupOnce;
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *exportedMethods;

@end
Expand Down Expand Up @@ -55,14 +54,10 @@ - (NSDictionary *)constantsToExport

- (dispatch_queue_t)methodQueue
{
__weak ABI35_0_0UMExportedModule *weakSelf = self;
dispatch_once(&_methodQueueSetupOnce, ^{
__strong ABI35_0_0UMExportedModule *strongSelf = weakSelf;
if (strongSelf) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[strongSelf class] exportedModuleName]];
strongSelf.methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
});
if (!_methodQueue) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[self class] exportedModuleName]];
_methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
return _methodQueue;
}

Expand Down
Expand Up @@ -18,7 +18,6 @@
@interface ABI36_0_0UMExportedModule ()

@property (nonatomic, strong) dispatch_queue_t methodQueue;
@property (nonatomic, assign) dispatch_once_t methodQueueSetupOnce;
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *exportedMethods;

@end
Expand Down Expand Up @@ -55,14 +54,10 @@ - (NSDictionary *)constantsToExport

- (dispatch_queue_t)methodQueue
{
__weak ABI36_0_0UMExportedModule *weakSelf = self;
dispatch_once(&_methodQueueSetupOnce, ^{
__strong ABI36_0_0UMExportedModule *strongSelf = weakSelf;
if (strongSelf) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[strongSelf class] exportedModuleName]];
strongSelf.methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
});
if (!_methodQueue) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[self class] exportedModuleName]];
_methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
return _methodQueue;
}

Expand Down
Expand Up @@ -20,7 +20,6 @@ @interface ABI37_0_0EXPermissions ()
@property (nonatomic, strong) NSMutableDictionary<NSString *, id<ABI37_0_0UMPermissionsRequester>> *requesters;
@property (nonatomic, strong) NSMapTable<Class, id<ABI37_0_0UMPermissionsRequester>> *requestersByClass;
@property (nonatomic, weak) ABI37_0_0UMModuleRegistry *moduleRegistry;
@property (nonatomic) dispatch_once_t requestersFallbacksRegisteredOnce;

@end

Expand Down Expand Up @@ -209,9 +208,7 @@ + (ABI37_0_0UMPermissionStatus)statusForPermission:(NSDictionary *)permission

- (id<ABI37_0_0UMPermissionsRequester>)getPermissionRequesterForType:(NSString *)type
{
dispatch_once(&_requestersFallbacksRegisteredOnce, ^{
[self ensureRequestersFallbacksAreRegistered];
});
[self ensureRequestersFallbacksAreRegistered];
return _requesters[type];
}

Expand Down
Expand Up @@ -18,7 +18,6 @@
@interface ABI37_0_0UMExportedModule ()

@property (nonatomic, strong) dispatch_queue_t methodQueue;
@property (nonatomic, assign) dispatch_once_t methodQueueSetupOnce;
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *exportedMethods;

@end
Expand Down Expand Up @@ -55,14 +54,10 @@ - (NSDictionary *)constantsToExport

- (dispatch_queue_t)methodQueue
{
__weak ABI37_0_0UMExportedModule *weakSelf = self;
dispatch_once(&_methodQueueSetupOnce, ^{
__strong ABI37_0_0UMExportedModule *strongSelf = weakSelf;
if (strongSelf) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[strongSelf class] exportedModuleName]];
strongSelf.methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
});
if (!_methodQueue) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[self class] exportedModuleName]];
_methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
return _methodQueue;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/@unimodules/core/CHANGELOG.md
Expand Up @@ -7,3 +7,5 @@
### 🎉 New features

### 🐛 Bug fixes

- Fixed a rare undetermined behavior that may have been a result of misuse of `dispatch_once_t` on iOS ([#7576](https://github.com/expo/expo/pull/7576) by [@sjchmiela](https://github.com/sjchmiela))
13 changes: 4 additions & 9 deletions packages/@unimodules/core/ios/UMCore/UMExportedModule.m
Expand Up @@ -18,7 +18,6 @@
@interface UMExportedModule ()

@property (nonatomic, strong) dispatch_queue_t methodQueue;
@property (nonatomic, assign) dispatch_once_t methodQueueSetupOnce;
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *exportedMethods;

@end
Expand Down Expand Up @@ -55,14 +54,10 @@ - (NSDictionary *)constantsToExport

- (dispatch_queue_t)methodQueue
{
__weak UMExportedModule *weakSelf = self;
dispatch_once(&_methodQueueSetupOnce, ^{
__strong UMExportedModule *strongSelf = weakSelf;
if (strongSelf) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[strongSelf class] exportedModuleName]];
strongSelf.methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
});
if (!_methodQueue) {
NSString *queueName = [NSString stringWithFormat:@"org.unimodules.%@Queue", [[self class] exportedModuleName]];
_methodQueue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
}
return _methodQueue;
}

Expand Down
1 change: 1 addition & 0 deletions packages/expo-permissions/CHANGELOG.md
Expand Up @@ -10,3 +10,4 @@

- Fix permissions in the headless mode. ([#7962](https://github.com/expo/expo/pull/7962) by [@lukmccall](https://github.com/lukmccall))
- Fixed `permission cannot be null or empty` error when asking for `WRITE_SETTINGS` permission on Android. ([#7276](https://github.com/expo/expo/pull/7276) by [@lukmccall](https://github.com/lukmccall))
- Fixed a rare undetermined behavior that may have been a result of misuse of `dispatch_once_t` on iOS ([#7576](https://github.com/expo/expo/pull/7576) by [@sjchmiela](https://github.com/sjchmiela))
Expand Up @@ -20,7 +20,6 @@ @interface EXPermissions ()
@property (nonatomic, strong) NSMutableDictionary<NSString *, id<UMPermissionsRequester>> *requesters;
@property (nonatomic, strong) NSMapTable<Class, id<UMPermissionsRequester>> *requestersByClass;
@property (nonatomic, weak) UMModuleRegistry *moduleRegistry;
@property (nonatomic) dispatch_once_t requestersFallbacksRegisteredOnce;

@end

Expand Down Expand Up @@ -209,9 +208,7 @@ + (UMPermissionStatus)statusForPermission:(NSDictionary *)permission

- (id<UMPermissionsRequester>)getPermissionRequesterForType:(NSString *)type
{
dispatch_once(&_requestersFallbacksRegisteredOnce, ^{
[self ensureRequestersFallbacksAreRegistered];
});
[self ensureRequestersFallbacksAreRegistered];
return _requesters[type];
}

Expand Down