CameraRoll: Use C atomic instead of OSAtomic
Summary: The last in my series of :atom: migrations. More to come! Closes https://github.com/facebook/react-native/pull/15279 Differential Revision: D5526467 Pulled By: javache fbshipit-source-id: 02b37387c8c47af9ffe42b938ddcf17eb15b916f
This commit is contained in:
parent
c06dd90dd4
commit
14f01bae86
|
@ -9,7 +9,7 @@
|
|||
|
||||
#import "RCTAssetsLibraryRequestHandler.h"
|
||||
|
||||
#import <libkern/OSAtomic.h>
|
||||
#import <stdatomic.h>
|
||||
|
||||
#import <AssetsLibrary/AssetsLibrary.h>
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
|
@ -41,13 +41,13 @@ RCT_EXPORT_MODULE()
|
|||
- (id)sendRequest:(NSURLRequest *)request
|
||||
withDelegate:(id<RCTURLRequestDelegate>)delegate
|
||||
{
|
||||
__block volatile uint32_t cancelled = 0;
|
||||
__block atomic_bool cancelled = ATOMIC_VAR_INIT(NO);
|
||||
void (^cancellationBlock)(void) = ^{
|
||||
OSAtomicOr32Barrier(1, &cancelled);
|
||||
atomic_store(&cancelled, YES);
|
||||
};
|
||||
|
||||
[[self assetsLibrary] assetForURL:request.URL resultBlock:^(ALAsset *asset) {
|
||||
if (cancelled) {
|
||||
if (atomic_load(&cancelled)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ RCT_EXPORT_MODULE()
|
|||
[delegate URLRequest:cancellationBlock didCompleteWithError:error];
|
||||
}
|
||||
} failureBlock:^(NSError *loadError) {
|
||||
if (cancelled) {
|
||||
if (atomic_load(&cancelled)) {
|
||||
return;
|
||||
}
|
||||
[delegate URLRequest:cancellationBlock didCompleteWithError:loadError];
|
||||
|
|
Loading…
Reference in New Issue