I've been experimenting with trying to create a timer with a
granularity of less than 1 millisecond. One of the things I've been
trying is using a thread to post custom Carbon events periodically to
the main application event queue. In my thread I have a loop which
uses MPDelayUntil() to pause for a little while and then post the
event. I have an event handler installed on the application to
process the event.
I've found that this process really effects the responsiveness of the
app, even if my event handler does nothing except return noErr. If I
make the thread wait two seconds before posting the event it takes a
while for anything to happen when I try and interact with the app.
For example, just trying to move the window is very difficult, you
start a window drag and then it catches up a while longer ( I'm
trying to avoid saying about 2 seconds longer :-). If I make the
thread wait a shorter time this improves, although even with a wait
of just 1 millisecond things are still pretty bad.
It almost seems like what I'm doing is stalling the event loop
somehow. I've done this before ( posting custom events from a thread
peridocially ) without this sort of trouble, so I'm a bit puzzled.
Here's the loop from my thread :
AbsoluteTime absTime = ::DurationToAbsolute( 1 );
while ( done == false )
::MPDelayUntil( &absTime );