• 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: Sublclassing NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sublclassing NSThread


  • Subject: Re: Sublclassing NSThread
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 17 Dec 2008 10:49:42 +0100


Le 17 déc. 08 à 10:32, Jean-Daniel Dupas a écrit :


And before you go off using NSOperationQueue, you should be aware that
it's broken on Leopard, as described in this thread:


http://www.cocoabuilder.com/archive/message/cocoa/2008/10/30/221452


We already discuss this issues, and I agree with previous post that said you misuse it:

http://www.cocoabuilder.com/archive/message/cocoa/2008/11/26/223819


I think NSOperationQueue should be used like this instead:
The process uses almost 200% of my Core 2 Duo proc and maybe i'm wrong, but I do not managed to crash it.


#import <Foundation/Foundation.h>

@interface Tester : NSObject {
  NSOperationQueue *_queue;
}

- (id)initWithQueue:(NSOperationQueue *)aQueue;
- (void)test;

@end

@implementation Tester

- (id)initWithQueue:(NSOperationQueue *)aQueue {
  if((self = [super init])) {
    _queue = [aQueue retain];
  }
  return self;
}

- (void)dealloc {
  [_queue release];
  [super dealloc];
}

- (void)test {
NSInvocationOperation *op = [[NSInvocationOperation alloc]
initWithTarget:self selector:_cmd object:nil];
[_queue addOperation:op];
[op release];
}


@end

int main(int argc, char **argv)
{
  [NSAutoreleasePool new];

NSMutableArray *testers = [NSMutableArray array];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
int i;
for(i = 0; i < 10; i++)
[testers addObject:[[[Tester alloc] initWithQueue:queue] autorelease]];


  for(Tester *tester in testers)
    [tester test];

  while(1) sleep(1000);
}


_______________________________________________

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: Sublclassing NSThread
      • From: "Michael Ash" <email@hidden>
References: 
 >Sublclassing NSThread (From: Brad O'Hearne <email@hidden>)
 >Re: Sublclassing NSThread (From: "Shawn Erickson" <email@hidden>)
 >Re: Sublclassing NSThread (From: "Bradley S. O'Hearne" <email@hidden>)
 >Re: Sublclassing NSThread (From: "Michael Ash" <email@hidden>)
 >Re: Sublclassing NSThread (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Saving NSImage with compression
  • Next by Date: Re: UNIX signals
  • Previous by thread: Re: Sublclassing NSThread
  • Next by thread: Re: Sublclassing NSThread
  • Index(es):
    • Date
    • Thread