On Jul 31, 2012, at 7:43 PM, Mr. Gecko <grmrge...@gmail.com> wrote:

> I need threads because the main thread is a network loop waiting for a 
> connection and when it gets a connection, it spawns a thread like in my 
> example. I need to be able to respond to the client with all the data from 
> the task and I need to close out the connection and release the spawned 
> thread/object.

You don't need threads for this, as long as you use asynchronous I/O.

> In response to number 2, how can I stop the run loop and how could I know 
> when I got everything? I don't have any way to verify I got everything.

You know you got everything when the pipe connected to the task's stdout 
reaches EOF.

You might find MYTask useful: it's a general-purpose wrapper around NSTask that 
I wrote a few years ago (while writing a Mercurial client that did its work by 
invoking the "hg" tool.) It was surprisingly difficult to get everything to 
work right.
        https://bitbucket.org/snej/myutilities/src/319441e240fa/MYTask.m
You're welcome to copy it (it's under a BSD license) or just use it as sample 
code to figure out how to use NSTask asynchronously.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to