YYKit
YYKit copied to clipboard
YYThreadSafeDictionary iOS 14.5 死锁问题
- 写Plist文件
[self.localNewPromptDic writeToFile:pListPath atomically:YES];
1.系统调用,此时申请了lock
- (void)enumerateKeysAndObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id key, id obj, BOOL *stop))block {
LOCK([_dic enumerateKeysAndObjectsWithOptions:opts usingBlock:block]);
}
- enumerateKeysAndObjectsWithOptions iOS 14.5 会调用 hash 以前系统不会,再次申请所了卡死
- (NSUInteger)hash {
LOCK(NSUInteger hash = [_dic hash]);
return hash;
}
建议:LOCK 改为递归锁?