Re: Help with threads and queues
Re: Help with threads and queues
- Subject: Re: Help with threads and queues
- From: Dave DeLong <email@hidden>
- Date: Thu, 29 Apr 2010 16:00:56 -0600
If you're worried about cross-platform compatibility, then use NSOperationQueue and NSOperations. The fundamental idea is identical (dispatch_queue = NSOperationQueue, dispatch_block = NSOperation), and on the platforms that have it, they've been re-written to use Grand Central Dispatch.
The only major difference is that you'll probably be creating NSInvocationOperations, which have to invoke a method on a target object, instead of being given a Block.
To answer your other questions:
1. You can suspend an NSOperationQueue using its "setSuspended:" method.
2. You can ask an NSOperationQueue for an array of its queued operations (the "operations" method)
3. Yes, it's NSOperationQueue. :)
4. NSOperationQueue sure does.
Cheers,
Dave
On Apr 29, 2010, at 3:41 PM, Paul Franz wrote:
> Do you know if it is available on the iPad? I think it is because
> according the Mac Rumors website says so. This is a back end code for
> a online board game and I am trying to port it over to the iPad. I
> figured the back end is the best place to start (i.e. avoid UI at the
> moment which will be a total re-write).
>
> Now if we assume that it is. The code goes from having a thread that
> pulls the data of the queue and pushing over the Internet. To a
> dispatch queue that calls a function that sends the data.
>
> Questions:
>
> 1) If the connection fails, can I suspend the processing of items on
> the queue from within the block?
> 2) Is there anyway to peek at the queue and find out how many
> "tasks" are queued up?
> 3) Is there a Cocoa wrapper for the dispatch code or will I need to
> create my own?
> 4) Do the dispatch queues work with Garbage Collection compiled code?
>
> Paul Franz
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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