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:
Adlai Holler 2017-07-31 03:17:39 -07:00 committed by Facebook Github Bot
parent c06dd90dd4
commit 14f01bae86
1 changed files with 5 additions and 5 deletions

View File

@ -9,7 +9,7 @@
#import "RCTAssetsLibraryRequestHandler.h" #import "RCTAssetsLibraryRequestHandler.h"
#import <libkern/OSAtomic.h> #import <stdatomic.h>
#import <AssetsLibrary/AssetsLibrary.h> #import <AssetsLibrary/AssetsLibrary.h>
#import <MobileCoreServices/MobileCoreServices.h> #import <MobileCoreServices/MobileCoreServices.h>
@ -41,13 +41,13 @@ RCT_EXPORT_MODULE()
- (id)sendRequest:(NSURLRequest *)request - (id)sendRequest:(NSURLRequest *)request
withDelegate:(id<RCTURLRequestDelegate>)delegate withDelegate:(id<RCTURLRequestDelegate>)delegate
{ {
__block volatile uint32_t cancelled = 0; __block atomic_bool cancelled = ATOMIC_VAR_INIT(NO);
void (^cancellationBlock)(void) = ^{ void (^cancellationBlock)(void) = ^{
OSAtomicOr32Barrier(1, &cancelled); atomic_store(&cancelled, YES);
}; };
[[self assetsLibrary] assetForURL:request.URL resultBlock:^(ALAsset *asset) { [[self assetsLibrary] assetForURL:request.URL resultBlock:^(ALAsset *asset) {
if (cancelled) { if (atomic_load(&cancelled)) {
return; return;
} }
@ -91,7 +91,7 @@ RCT_EXPORT_MODULE()
[delegate URLRequest:cancellationBlock didCompleteWithError:error]; [delegate URLRequest:cancellationBlock didCompleteWithError:error];
} }
} failureBlock:^(NSError *loadError) { } failureBlock:^(NSError *loadError) {
if (cancelled) { if (atomic_load(&cancelled)) {
return; return;
} }
[delegate URLRequest:cancellationBlock didCompleteWithError:loadError]; [delegate URLRequest:cancellationBlock didCompleteWithError:loadError];