Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading Question?




On 12 Mar 2007, at 13:06, Dave wrote:

Hi,

I have a Carbon Dynamic Library (built using XCode) that is a plug- in to another application. Basically it uses QuickTime to grab frames of a movie and then analyzes each frame and produces a report at the end.

It works really well, except that it hogs the processor and the host application is locked out until the end of the movie.

What I would like to be able to do is to Start up a new thread when I get called and have this process the movie. The host application would then "poll" via a "Are you done?" API which would return "no" until the other thread had finished?

How can I go about doing this? What documents should I look at? What is the recommend API to use? Is there any sample code I could look at?

http://developer.apple.com/technotes/tn/tn2028.html lists the various threading APIs, you would probably want to use the MP tasks API. The document isn't terribly up to date but then nothing much has changed in that area (from the point of view of the threading models available). Assuming the processing you are doing is all threadsafe then I don't see why this wouldn't work.
The MP api provides communication mechanisms (queues, semaphores etc...) but these days I find the nicest way is to use carbon events (just be sure you're posting to the event queue for the correct thread). The HIobjectThreadController (http://developer.apple.com/ samplecode/HIObjectThreadController/ ) sample shows that kind of thing.


Fred

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Threading Question? (From: Dave <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.