Re: Run Loops
Re: Run Loops
- Subject: Re: Run Loops
- From: Chris Kane <email@hidden>
- Date: Tue, 31 Jul 2001 07:43:44 -0700
On Monday, July 30, 2001, at 12:36 PM, Vincent Predoehl wrote:
>
On Thursday, July 26, 2001, at 09:24 PM, Chris Kane wrote:
>
> So, if you don't run the run loop often, a message about needing the
>
> next sound data buffer (using the example from above) from the kernel
>
> driver will sit in a queue until you do run the run loop, and sound
>
> playback might have crackling or blanks if the next buffer isn't
>
> delivered soon enough because the message languished. In the case of
>
> sound play (record is even worse) it is important to respond to these
>
> things quickly and in a timely fashion, so most of the time in your
>
> engine should be spent in the run loop waiting for these things so
>
> that CoreAudio gets them as quickly as possible.
>
>
This is great information. It may be preferable for us to instantiate
>
a child pthread and use that solely for the run loop instead of the
>
engine's main loop. Are there any implications that go with doing that?
Well, you have to know which run loop CoreAudio is going to put its run
loop sources in. Each thread has a distinct and separate run loop.
Generally things will put their sources in the run loop of the thread in
which the code has been executed; that is, if you start the CoreAudio
stuff up that requires notifications from the kernel [or, whatever
CoreAudio is doing], I would expect the run loop of that thread which
started that up to have the source registered with it. Of course, you
nominally don't know what CoreAudio is doing with run loop sources or
when it is creating and registering them with a run loop, so it may be
safest to do as much as you can of the CoreAudio stuff in that side
thread.
>
Also, has Apple released any documentation on run loops? I can't find
>
any, but I may be looking in the wrong place.
There is no documentation on CFRunLoop yet. The CFRunLoop.h in Darwin
has some header doc, which will also be in 10.1, but it is hardly
complete yet.
Chris Kane
Cocoa Frameworks, Apple