我有这款应用程序是在iPhone 4启动时为iPhone 4创建的。现在,这个应用程序没有在iPhone 4S上运行。iPhone - Grand Central Dispatch在iPhone 4S上无法正常工作
我已经确定罪魁祸首部分为GCD部分。这里是:
dispatch_group_t my_group = dispatch_group_create();
dispatch_queue_t queue1 =
dispatch_queue_create("Queue 1", NULL);
dispatch_queue_t queue2 =
dispatch_queue_create("Queue 2", NULL);
dispatch_group_async(my_group, queue1, ^{
[self doStuff1];
});
dispatch_group_async(my_group, queue2, ^{
[self doStuff2];
});
dispatch_group_notify(my_group, dispatch_get_main_queue(), ^{
// this is block 3, this is to be executed after both queues end processing
// this is never executed on iPhone 4S, but is executed on iPhone4
// no error message, but execution never starts inside this block
});
想法是这样的:创建两个队列和一个组。我使用组来异步地为这两个队列发送任务。当两者都完成后,该组发射另一块任务。
这项工作奇妙的iPhone 4,但最终块3永远不会到达。
有什么理由呢?任何线索?
谢谢。
在iPad 2上运行测试多核理论的一种方法(这也是我的猜测)。从来没有线程问题的保证,但它们确实倾向于使用多核心更容易地暴露出来。 –
@DavidDunham - 在多核Mac上运行时,我还在iOS Simulator中暴露了类似的错误。这是模拟器可以派上用场的其中一例。您还可以使用CPUPalette应用程序在Mac上实时打开和关闭核心,但我现在无法在Lion系统上找到它。 –
@BradLarson这个代码的问题在于我不能使用模拟器,因为它需要coremotion和一些硬件功能。 – SpaceDog