Re: NSOperationQueue
Re: NSOperationQueue
- Subject: Re: NSOperationQueue
- From: John Love <email@hidden>
- Date: Sun, 21 Sep 2008 16:46:48 -0400
has wrote:
Getting back to the main discussion of the OP's threading/
NSOperationQueue problems, perhaps it would help if he backs up a
bit and explains in general terms what he's trying to achieve,
rather than focus on individual details of how he's currently trying
to do it? That way, folks might be able to suggest a better overall
solution, rather than getting bogged down in the details of the
current, potentially misconceived, approach.
Before I write a short answer to this good question .. Mike, I'm am no
longer crashing into the debugger and am down to trying to get my -
startCalculation into a separate thread. Also, I ditched -
waitUntilAllOperationsAreFinished in order to implement what you
stated, namely:
=====
I would expect you to queue an NSOperation in the loop and if you
really need to wait until all of them are done executing then you
could wait after the loop. Note though, that you would still be
blocking the main thread. But at least you would be taking advantage
of NSOperationQueue's ability to schedule multiple operations in
parallel depending on available system resources.
=====
Back to has' big picture question ...
has, I have a rather lengthy series of calculations to do, hopefully
in a separate thread. In my "main.m", I init my NSOperationQueue as a
global, but do not add any NSInvocationOperation's to it. In my main
thread, I call -startCalculation to do exactly that. The very first
statement in -startCalculation is a for-loop with a row-counter, and
for each iteration of this counter I add one Operation to the queue.
As my sidebar to Mike stated, I ditched -
waitUntilAllOperationsAreFinished for each row in the for-loop for
Mike's reason above.
That's it,
John
_______________________________________________
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