Re: Help with threads and queues

2010-04-30 Thread Paul Franz
Oooohh. Cool. Definitely going to get it. Paul Franz On Fri, Apr 30, 2010 at 10:55 AM, James Bucanek wrote: > Paul Franz wrote (Thursday, April 29, 2010 > 5:26 AM -0400): > >> I am trying to convert my Java code to Objective-C code and I have run >> into a problem

Re: Help with threads and queues

2010-04-30 Thread James Bucanek
Paul Franz wrote (Thursday, April 29, 2010 5:26 AM -0400): I am trying to convert my Java code to Objective-C code and I have run into a problem. < clip > How do you do the samething in Cocoa/Objective-C? WARNING: Gratuitous, self-serving, book plug coming up

Re: Help with threads and queues

2010-04-29 Thread Paul Franz
Thanks. That looks like what I am looking for. Note: I didn't know that about NSOperationQueue. Paul Franz On Thu, Apr 29, 2010 at 6:00 PM, Dave DeLong wrote: > If you're worried about cross-platform compatibility, then use > NSOperationQueue and NSOperations.  The fundamental idea is identica

Re: Help with threads and queues

2010-04-29 Thread Dave DeLong
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 o

Re: Help with threads and queues

2010-04-29 Thread David Duncan
On Apr 29, 2010, at 2: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. I would recommend against reading rumor sites for determining supported API :). GCD and Blocks are not available on iPhone OS 3.2. -- Da

Re: Help with threads and queues

2010-04-29 Thread Paul Franz
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 to

Re: Help with threads and queues

2010-04-29 Thread Dave DeLong
Whoops, that should've been dispatch_async and not dispatch_queue_async. Silly typing code in an email window... Dave On Apr 29, 2010, at 10:26 AM, Dave DeLong wrote: > #import > > //somewhere reasonably accessible to your producer: > dispatch_queue_t mySerialQueue = > dispatch_queue_create(

Re: Help with threads and queues

2010-04-29 Thread Thomas Clement
See the man pages and the Concurrency Programming Guide. man dispatch_queue_create man dispatch_async http://developer.apple.com/mac/library/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html On Apr 29, 2010, at 6:19 PM, Paul Franz wrote: Where can I

Re: Help with threads and queues

2010-04-29 Thread Jens Alfke
On Apr 29, 2010, at 5:26 AM, Paul Franz wrote: I am trying to convert my Java code to Objective-C code and I have run into a problem. I have thread, that currently has a socket open and it sits there and send packets of information through the socket. If you want to port existing code with th

Re: Help with threads and queues

2010-04-29 Thread Dave DeLong
#import //somewhere reasonably accessible to your producer: dispatch_queue_t mySerialQueue = dispatch_queue_create("franz.p.paul.myserialqueue", NULL); //in your producer: id newResource = ; // the thing you want to notifyAll() about dispatch_queue_async(mySerialQueue, ^{ /** do somet

Re: Help with threads and queues

2010-04-29 Thread Paul Franz
Where xan I find an example of a serial dispatch queue? Sent from my iPhone On Apr 29, 2010, at 11:35 AM, Thomas Clement wrote: Just use a serial dispatch queue (or if you need to run pre-10.6 use an NSOperationQueue with a max concurrent count set to 1) and dispatch operations to the queu

Re: Help with threads and queues

2010-04-29 Thread Thomas Clement
Just use a serial dispatch queue (or if you need to run pre-10.6 use an NSOperationQueue with a max concurrent count set to 1) and dispatch operations to the queue whenever you want. The operation passed to the queue should write some data to the socket. Thomas On Apr 29, 2010, at 2:26 PM, P

Re: Help with threads and queues

2010-04-29 Thread Dave DeLong
You'll basically be writing a custom object to wrap an NSArray in an object with a semaphore to make it threadsafe. Arrays are not threadsafe by default. Cocoa doesn't have a semaphore object beyond the NSLock mutex. However, you can find an implementation of a semaphore here: http://cocoahead

Help with threads and queues

2010-04-29 Thread Paul Franz
I am trying to convert my Java code to Objective-C code and I have run into a problem. I have thread, that currently has a socket open and it sits there and send packets of information through the socket. Currently my queue code uses the wait/notifyAll methods in Java to put the thread into a wait