• 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: async NSOperation and NSOperationQueue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: async NSOperation and NSOperationQueue


  • Subject: Re: async NSOperation and NSOperationQueue
  • From: John Love <email@hidden>
  • Date: Mon, 15 Sep 2008 11:02:21 -0400

Ken Thomases wrote:

[quote]
Note that if you don't make your operation "concurrent" in this
sense, but you queue it in an NSOperationQueue, that queue will still
run it asynchronously, in its own thread, concurrently with other
operations.  It's just that, for non-"concurrent" operations,
NSOperationQueue knows it has to manage the execution context itself
(by spinning off a thread)
[end quote]

I must be doing something terribly wrong, because when I start up the NSOperationQueue that does some time consuming calculations, I do not get back control of my application until after the lengthy calculation is complete. Here are the relevant code snippets:

- (void) calculateWorksheetRow:(id)data {
     // takes a long time here
}


- (void) startQueue {
theQueue = [[[NSOperationQueue alloc] init] autorelease];
theOp = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(calculateWorksheetRow:)
object:nil];
[theQueue addOperation:theOp];
}



- (void) stopQueue { [theQueue cancelAllOperations]; // [theQueue release]; // [ ... autorelease] [theOp release]; }


- (void) startCalculation { int row; for (row=1; row < 100; row++) { // stuff here [self startQueue]; // start new thread // [theQueue waitUntilAllOperationsAreFinished]; } // more stuff }



John Love
Touch the Future! Teach!



_______________________________________________

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: async NSOperation and NSOperationQueue
      • From: Jason Coco <email@hidden>
    • Re: async NSOperation and NSOperationQueue
      • From: Benjamin Stiglitz <email@hidden>
  • Prev by Date: Re: Do I Need Multiple NSArrayControllers For This?
  • Next by Date: Can't get to work setDoubleAction on NSMatrix with NSButtonCell
  • Previous by thread: Re: Getting NSTimeZone for a given NSDate
  • Next by thread: Re: async NSOperation and NSOperationQueue
  • Index(es):
    • Date
    • Thread