Skip navigation.
 
mlRe: MPTask equivalent?
FROM : Trygve Inda
DATE : Mon Mar 10 22:05:37 2008

>> 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.



I would like to use NSThreads as they seem simpler and Apple's latest docs
discourages MPTasks.

The call I need an equivalent to is MPWaitOnQueue... This blocks a thread
until a message is received OR it times out. Is there a way to get a similar
functionality with NSThread?

Basically I want to do a bit of processing, then wait for say 5 seconds, but
in the interim, I want to be able to send a abort signal to the thread so
that if I need to end the thread it can safely exit asap.

Thanks,

Trygve

Related mailsAuthorDate
mlMPTask equivalent? Trygve Inda Feb 20, 20:03
mlRe: MPTask equivalent? j o a r Feb 20, 20:22
mlRe: MPTask equivalent? Charles Steinman Feb 20, 21:09
mlRe: MPTask equivalent? Adam P Jenkins Feb 20, 22:32
mlRe: MPTask equivalent? Trygve Inda Feb 21, 16:10
mlRe: MPTask equivalent? Trygve Inda Feb 21, 16:14
mlRe: MPTask equivalent? j o a r Feb 21, 16:20
mlRe: MPTask equivalent? Scott Ribe Feb 22, 17:33
mlRe: MPTask equivalent? Trygve Inda Mar 10, 22:05
mlRe: MPTask equivalent? Hamish Allan Mar 10, 22:41
mlRe: MPTask equivalent? Ken Thomases Mar 11, 06:40