嗨,我有以下代码,我的问题是,有时它永远不会出现在dispatch_sync
块死锁情况下。我已经搜索过,但是没有解决方案。谁能帮忙找出原因并加以解决。
connectionQueue = dispatch_queue_create("YapDatabaseConnection", NULL);
dispatch_sync(connectionQueue, ^{ @autoreleasepool {
NSLog(@"read block_sync :started");
if (longLivedReadTransaction)
{
NSLog(@"read block_sync :started1 %@",longLivedReadTransaction);
block(longLivedReadTransaction);
}
else
{
YapDatabaseReadTransaction *transaction = [self newReadTransaction];
NSLog(@"read block_sync :started2 %@",transaction);
[self preReadTransaction:transaction];
NSLog(@"read block_sync :1 %@",transaction);
block(transaction);
NSLog(@"read block_sync :2 %@",transaction);
[self postReadTransaction:transaction];
NSLog(@"read block_sync :3 %@",transaction);
}
}});