YYKit icon indicating copy to clipboard operation
YYKit copied to clipboard

YYThreadSafeDictionary iOS 14.5 死锁问题

Open ganvinalix opened this issue 4 years ago • 0 comments

  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 改为递归锁?

ganvinalix avatar Feb 03 '21 06:02 ganvinalix