RCTImage: Use C atomics instead of OSAtomic

Summary:
The next in my series of :atom: migrations.
Closes https://github.com/facebook/react-native/pull/15278

Differential Revision: D5526468

Pulled By: javache

fbshipit-source-id: 91511c69bc37a6f1382bcf0b0dd847adf10fd43a
This commit is contained in:
Adlai Holler
2017-08-01 02:48:28 -07:00
committed by Facebook Github Bot
parent e248980980
commit 114b0801ce
3 changed files with 33 additions and 24 deletions

View File

@@ -9,7 +9,7 @@
#import "RCTImageStoreManager.h"
#import <libkern/OSAtomic.h>
#import <stdatomic.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTType.h>
@@ -137,14 +137,14 @@ RCT_EXPORT_METHOD(addImageFromBase64:(NSString *)base64String
- (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);
};
// Dispatch async to give caller time to cancel the request
dispatch_async(_methodQueue, ^{
if (cancelled) {
if (atomic_load(&cancelled)) {
return;
}