Re: Alternative to Delay()
Re: Alternative to Delay()
- Subject: Re: Alternative to Delay()
- From: "B.J. Buchalter" <email@hidden>
- Date: Tue, 29 Jul 2003 17:42:07 -0400
on 7/29/03 3:53 PM, Brian Willoughby at email@hidden wrote:
>
>
However, despite the official documented recommendation, a loop calling
>
TrackMouseLocation is still not the nicest coding technique in terms of
>
multi-processing and user interaction. Such a loop simplifies the programmers
>
job, but does not always use the CPU efficiently. As a rule, any time the
>
code is looping while polling for a change in state, this code is wasting
>
some amount of CPU.
This is not true for the TrackMouseLocation call. The TrackMouseLocation is
sort of like a return to the event loop with event filters. Carbon timers
still get dispatched, and the UI thread blocks until an event is delivered
(e.g. Mouse Moved, modifiers changed, timeout, etc.) Since the timeout is
not required, TrackMouseLocation with no timeout is virtually equivalent to
what you describe without the requirement of a global state machine. In
particular, the thread definitely blocks and does not spin CPU looping. For
existing apps based upon the old, old model, it is pretty easy to recode
tracking loops with TrackMouseLocation and thus get the benefit of blocking
and timers without having to completely change program logic. For a local
tracking loop, it is not clear to me that it is really beneficial to have a
global state machine for the app -- it seems overly complex. The only thing
that I see happen is that if some asynch event occurs, it will remain queued
until the user releases the mouse. This seems like a good thing (except for
some pathological cases) -- e.g., in our app, the UI can change when devices
are attached or disconnected -- and it would be weird if the happened while
the user was dragging something, etc.
Can you point to any user benefit of being fully reentrant on the UI thread
while the user is actively interacting with the app?
Now this is probably off the point of the original Delay question -- which I
agree is not a great user experience. But TrackMouseLocation used properly
is pretty cool.
Best regards,
B.J. Buchalter
Metric Halo
M/S 601 - Building 8
Castle Point Campus
Castle Point, NY 12511-0601 USA
tel +1 845 831-8600
fax +1 603 250-2451
If you haven't heard ChannelStrip yet, you don't know what you're missing!
Check out SpectraFoo, ChannelStrip and Mobile I/O at
http://www.mhlabs.com/
Download a 12 day demo from <
http://www.mhlabs.com/demo/>
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.