以下代码创建了一个主线程超时和被杀应用程序的场景。我不明白为什么。
此方法由主线程调用,并且根据堆栈跟踪,此调用不是同步的(它直接从main.m触发)。然而,为什么需要20多秒才能完成?在计时器触发后,此事件是否仅
。[fooObj performSelector:@selector(populate) withObject:nil afterDelay:2];
崩溃日志:
经过的总CPU时间(秒):20.060(用户20.060,系统0.000), 100%CPU经过的应用程序CPU时间(秒):19.438,97%CPU
线程0名称:调度队列:com.apple.main-thread线程0:0
CoreFoundation 0x3ad408b4 CFArrayGetFirstIndexOfValue + 3481 CoreFoundation 0x3ad46e88 CFRunLoopRemoveTimer + 224
2 CoreFoundation 0x3ad46d00 CFRunLoopTimerInvalidate + 324
3 MyApp 0x00034b94 - [容器清除](Container.m:147)
4 MyApp 0x000348aa - [容器填充](Container.m:77)
5 MyApp 0x00034f62 - [BaseContainer populate](BaseContainer.m:75)
6基金会0x35bfaa6a __NSFireDelayedPerform + 446
7 CoreFoundation 0x3add45dc CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 12
8 CoreFoundation 0x3add428c __CFRunLoopDoTimer + 268
9 CoreFoundation 0x3add2efc __CFRunLoopRun + 1228 10
10 CoreFoundation 0x3ad45eb8 CFRunLoopRunSpecific + 352
11 CoreFoundation 0x3ad45d44 CFRunLoopRunInMode + 100
12 GraphicsServices 0x391132e6 GSEventRunModal + 70
13 UIKit 0x33f852f4 UIApplicationMain + 1116
14 MyApp 0x000029c6 main(main.m:14)
出于同样的原因,这是另一次崩溃:MT超时。 (似乎从日志中,线程0正在等待它自己的互斥锁被释放。死锁或误读日志?)
经过的总CPU时间(秒):20.060(用户20.060,系统0.000),100%CPU 经过的应用程序CPU时间(秒):18.175,91%CPU
线程0名称:Dispatch queue:com.apple.main-thread 线程0:
0 libsystem_kernel.dylib 0x32af50fc __psynch_mutexwait + 24
1 libsystem_c.dylib 0x35e56124 pthread_mutex_lock + 388
2 CoreFoundation 0x3ad46df8 CFRunLoopRemoveTimer + 80
3基金会0x35bfaa20 __NSFireDelayedPerform + 372
4 CoreFoundation 0x3add45dc CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 12
5 CoreFoundation 0x3add428c __CFRunLoopDoTimer + 268
6 CoreFoundation 0x3add2efc __CFRunLoopRun + 1228
7 CoreFoundation 0x3ad45eb8 CFRunLoopRunSpecific + 352
8 CoreFoundation 0x3ad45d44 CFRunLoopRunInMode + 100
9 GraphicsServices 0x391132e6 GSEventRunModal + 70
10 UIKit 0x33f852f4 UIApplicationMain + 1116
11空间的心脏0x000029c6 main(main.m:14)
12个空心之心0x00002980 0x1000 + 6528
编辑:添加了清晰和填充的impl。如您所见,没有阻止呼叫。
- (void)clear
{
self.m_msdData = [NSMutableData dataWithLength:0];
self.m_maItems = [NSMutableArray arrayWithCapacity:0];
self.m_mdItems = [NSMutableDictionary dictionaryWithCapacity:0];
[m_timer invalidate];
self.m_timer = nil;
self.m_nsUrlConnection = nil;
// zz Don't change the property state, in case an observer is already listening.
m_nState = CS_UNPOPULATED;
}
- (CONTAINER_STATE)populate
{
[self clear];
self.m_timer = [NSTimer scheduledTimerWithTimeInterval:TIME_OUT_SEC
target:self
selector:@selector(timeout)
userInfo:nil
repeats:NO];
self.m_nState = CS_POPULATING;
return CS_POPULATING;
}