Remove dispatch_queue_async_safe && optimize dispatch_main_async_safe

This commit is contained in:
zhongwuzw 2018-05-21 17:51:07 +08:00
parent 55d65569dc
commit 7d170d47d9
1 changed files with 4 additions and 8 deletions

View File

@ -87,15 +87,11 @@ typedef void(^SDWebImageNoParamsBlock)(void);
FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain;
#ifndef dispatch_queue_async_safe
#define dispatch_queue_async_safe(queue, block)\
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\
#ifndef dispatch_main_async_safe
#define dispatch_main_async_safe(block)\
if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {\
block();\
} else {\
dispatch_async(queue, block);\
dispatch_async(dispatch_get_main_queue(), block);\
}
#endif
#ifndef dispatch_main_async_safe
#define dispatch_main_async_safe(block) dispatch_queue_async_safe(dispatch_get_main_queue(), block)
#endif