Open JunyuKuang opened 7 years ago
I have added these changes and its working. UIKit added just because I had to keep the backward compatibility.
#import <os/lock.h>
#import <UIKit/UIKit.h>
static void aspect_performLocked(dispatch_block_t block) {
- static OSSpinLock aspect_lock = OS_SPINLOCK_INIT;
- OSSpinLockLock(&aspect_lock);
- block();
- OSSpinLockUnlock(&aspect_lock);
+
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
+ if(([[[UIDevice currentDevice] systemVersion] compare:@"10.0" options:NSNumericSearch] != NSOrderedAscending)){
+ static os_unfair_lock aspect_lock = OS_UNFAIR_LOCK_INIT;
+ os_unfair_lock_lock(&aspect_lock);
+ block();
+ os_unfair_lock_unlock(&aspect_lock);
+ }
+ #else
+ else{
+ static OSSpinLock aspect_lock = OS_SPINLOCK_INIT;
+ OSSpinLockLock(&aspect_lock);
+ block();
+ OSSpinLockUnlock(&aspect_lock);
+ }
+ #endif
}
Is that worth it? It's not like spin locks no longer work. Aspects evolved internally at PSPDFKit a bit but we use our own wrapper for locking. I will clean that up once we internally drop iOS 9... easier.
Hi, after I update my app's minimum iOS version to 10.0, I get this warning: 'OSSpinLock' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock() from <os/lock.h> instead
I tried to fix it by myself but found it more complicate than I expected.