• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOperationQueue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSOperationQueue
      • From: Mike Fischer <email@hidden>
  • Prev by Date: Re: escaping a string
  • Next by Date: How to load a window
  • Previous by thread: Re: NSOperationQueue
  • Next by thread: Re: NSOperationQueue
  • Index(es):
    • Date
    • Thread