Re: Processing multiple objects w/NSTasks efficiently?
Re: Processing multiple objects w/NSTasks efficiently?
- Subject: Re: Processing multiple objects w/NSTasks efficiently?
- From: Pontus Ilbring <email@hidden>
- Date: Tue, 8 Nov 2005 01:38:43 +0100
On 11/8/05, Michael Carter <email@hidden> wrote:
> Hello all.
>
> I could use some advise on a project I'm working on.
>
> I need to query information from a couple hundred servers in an
> efficient manner using a central application. My initial approach is
> to create an array of objects which each contain an NSTask. This task
> pulls information from a remote host using an ssh call in order to
> display key info in an NSTableView. The columns of the tableview are
> bound to the parameters needing display.
>
> What I'd like to do is write the app so that this is all done
> asynchronously so that the user needn't sit there and watch the ball
> spin. What would be the best practice for such an approach? I've
> tried creating a single thread that iterates the objects and tells
> them to start their tasks. I currently use
> makeObjectsPerformSelector: but only one server at a time is polled.
> The whole operation isn't really asynchronous since I found I had to
> use NSTask's waitUntilExit to process each task.
>
> Is there a better way to do this?
In concurrent programming there's a design called a "bag of tasks".
The basic idea is that you have a shared object, the bag, holding
tasks, and a set of worker threads that continuously remove a task
from the bag and perform it.
Implementation is trivial unless you want to know when all worker
threads are idle, which you usually do. But even then it's fairly
easy.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden