Re: MPTask equivalent?
Re: MPTask equivalent?
- Subject: Re: MPTask equivalent?
- From: Scott Ribe <email@hidden>
- Date: Fri, 22 Feb 2008 09:33:03 -0700
- Thread-topic: MPTask equivalent?
> Is there a way to mix MPTasks in Cocoa? I am really eager to use Cocoa here
> as many things are much easier than in Carbon (less code), but the
> task/multithreading of Cocoa seems weak.
Yes, you can create MPTasks from Cocoa, and use Cocoa from MPTasks. The key
is that there's a whole lot of Cocoa that's not thread-safe, but you can
certainly call performSelectorOnMainThread:withObject:waitUntilDone: from an
MPTask. Object allocation is thread safe, so you can create Objective-C
objects to pass through to that call, and you can create your own
Objective-C classes that are thread-safe.
You can also pass pointers to Objective-C objects through MPQueues. Just
watch out for the race condition of passing an autoreleased object via an
MPQueue--retain the object before putting it on the queue and release it (at
a CORRECT time) after getting it from the queue.
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden