Permalink
Browse files

CameraRoll: Use C atomic instead of OSAtomic

Summary:
The last in my series of :atom: migrations. More to come!
Closes #15279

Differential Revision: D5526467

Pulled By: javache

fbshipit-source-id: 02b37387c8c47af9ffe42b938ddcf17eb15b916f
  • Loading branch information...
Adlai-Holler authored and facebook-github-bot committed Jul 31, 2017
1 parent 7c528cd commit 52d546caa272199212f70d0ed834658aabaf99be
Showing with 5 additions and 5 deletions.
  1. +5 −5 Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m
@@ -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 @@ - (BOOL)canHandleRequest:(NSURLRequest *)request
- (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 @@ - (id)sendRequest:(NSURLRequest *)request
[delegate URLRequest:cancellationBlock didCompleteWithError:error];
}
} failureBlock:^(NSError *loadError) {
if (cancelled) {
if (atomic_load(&cancelled)) {
return;
}
[delegate URLRequest:cancellationBlock didCompleteWithError:loadError];

0 comments on commit 52d546c

Please sign in to comment.