diff --git a/RCTAssetsLibraryRequestHandler.m b/RCTAssetsLibraryRequestHandler.m index 58862354f..30a3baf65 100644 --- a/RCTAssetsLibraryRequestHandler.m +++ b/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];