ibireme / YYKit

A collection of iOS components.
MIT License
13.99k stars 3.7k forks source link

YYThreadSafeDictionary iOS 14.5 死锁问题 #582

Open ganvinalix opened 3 years ago

ganvinalix commented 3 years ago
  1. 写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]);
}
  1. enumerateKeysAndObjectsWithOptions iOS 14.5 会调用 hash 以前系统不会,再次申请所了卡死
    - (NSUInteger)hash {
    LOCK(NSUInteger hash = [_dic hash]);
    return hash;
    }

建议:LOCK 改为递归锁?