Re: MPTask equivalent?
Re: MPTask equivalent?
- Subject: Re: MPTask equivalent?
- From: Trygve Inda <email@hidden>
- Date: Mon, 10 Mar 2008 21:05:37 +0000
- 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.
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
_______________________________________________
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