dispatch_sync永远不会从块中回来

时间:2018-06-23 07:16:33

标签: ios grand-central-dispatch objective-c-blocks

嗨,我有以下代码,我的问题是,有时它永远不会出现在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);
        }
    }});

0 个答案:

没有答案