mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-11 10:38:00 +08:00
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:
committed by
Facebook Github Bot
parent
e248980980
commit
114b0801ce
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user