多线程来自哪里?

时间:2012-07-24 20:30:43

标签: objective-c ios multithreading audio

我遇到了多线程问题。在我正在排序和修改NSOrderedSet的代码位置周围放置了一个很好的@synchronized {}似乎清理了我正在阅读它的部分中的问题。我现在的问题是试图找出我的其他线程来自哪里,以便我能更好地理解我的代码。这些片段中的任何一个都会导致新的线程吗?

CADisplayLink* gameTimer;
gameTimer = [CADisplayLink
             displayLinkWithTarget:self
             selector:@selector(updateDisplay:)];

[gameTimer addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

和/或这是否会启动一个帖子?

 AURenderCallbackStruct callbackStruct;
 callbackStruct.inputProc = PerformThru;
 callbackStruct.inputProcRefCon = &_effectState;

 AudioUnitSetProperty(      _effectState.rioUnit, 
                            kAudioUnitProperty_SetRenderCallback,
                            kAudioUnitScope_Global, 
                            bus0, 
                            &callbackStruct, 
                            sizeof(callbackStruct);
 AudioOutputUnitStart(_effectState.rioUnit);

我猜测后者因为在PerformThru函数中我开始看到像

这样的调试消息
   Object 0x682ec20 of class __NSOrderedSetM autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

但是,主要是我有@autoreleasepool ..所以我猜测有一些东西导致另一个线程。

1 个答案:

答案 0 :(得分:2)

音频单元渲染回调将在私有(到Core Audio)后台线程中调用。您可以通过在PerformThru()中放置一个断点并注意到调试器停止的堆栈帧不在主线程/队列中来看到这一点。

相关问题