From 52d546caa272199212f70d0ed834658aabaf99be Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Mon, 31 Jul 2017 03:17:39 -0700 Subject: [PATCH] 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 --- Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m b/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m index 58862354ff..30a3baf651 100644 --- a/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m +++ b/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m @@ -9,7 +9,7 @@ #import "RCTAssetsLibraryRequestHandler.h" -#import +#import #import #import @@ -41,13 +41,13 @@ RCT_EXPORT_MODULE() - (id)sendRequest:(NSURLRequest *)request withDelegate:(id)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];