• 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: alloc init thread safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alloc init thread safe?


  • Subject: Re: alloc init thread safe?
  • From: David Carlisle <email@hidden>
  • Date: Thu, 8 Mar 2007 15:05:16 -0700

Thanks j o a r.  I can see I'm being sloppy in my informal terminology.

I can post the init methods, as Bill requested.

%¾GINCODE%%

@interface MyNSObject : NSObject {
}    // No variables and no init method
- (void) exception:(NSString *)s2;
@end


@interface Methods : MyNSObject { BOOL MethodsTerminated; }

@implementation Methods

- (id) init {
	[super init];
	MethodsTerminated = NO;
	return self;
}

@end

@interface ControlMethods2 : Methods {
	ControlDom2 *C;
}
@end

@implementation ControlMethods2

- (id) init {
	[super init];
	if (LC(LC_ThreadState)) NSLog(@"ControlMethods2 init for %@", self);
	C = [self CM_CD_alloc_init];
	[C retain];
	return self;
}

@end

@interface CM_Analyzers : ControlMethods2 {
	NSString *CM_LocalText;
}
@end;

@implementation CM_Analyzers

- (id) init {
	[super init];
	CM_LocalText = nil;
	return self;
}

end;

@implementation LTX_Analyzers

- (ControlMethods2 *) CM_alloc_init {
	// [alloc_init_Lock lock];
	CM_Analyzers *CM = [[CM_Analyzers alloc] init];
	// [alloc_init_Lock unlock];
	return CM;
}

@end;

// called within a superclass of LTX_Analyzers:

ControlMethods2 *CM = [self CM_alloc_init];
[CM retain];
if (LC(LC_ThreadState)) NSLog(@"has CM: %@", CM);

// This occasionally returns "has CM: (null)"

%%ENDCODE%%

On Mar 8, 2007, at 2:11 PM, j o a r wrote:


On 8 mar 2007, at 21.54, David Carlisle wrote:

The init methods in the hierarchy of superclasses are fairly simple.

Can you post all relevant code to the list? From the information posted so far, I think that the most likely reason for your problems would still have to be thread safety errors on your part.


Even better, create a small sample project that reproduce the problem and post it online somewhere. It should be easy enough if there really is a bug in the default implementations of +alloc or - init.

As a side note: In your own code you can call your methods whatever you want to of course, but for your own sake I would suggest that you adhere to standard ObjC/Cocoa naming conventions when you post code snippets to the mailing list. Calling a method "C2_alloc_init", and referring to it as the "alloc init method" is bound to cause massive confusion among the people who you are looking to for assistance.

j o a r



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: alloc init thread safe?
      • From: James Bucanek <email@hidden>
    • Re: alloc init thread safe?
      • From: j o a r <email@hidden>
References: 
 >alloc init thread safe? (From: email@hidden)
 >Re: alloc init thread safe? (From: Chris Suter <email@hidden>)
 >Re: alloc init thread safe? (From: David Carlisle <email@hidden>)
 >Re: alloc init thread safe? (From: "Shawn Erickson" <email@hidden>)
 >Re: alloc init thread safe? (From: David Carlisle <email@hidden>)
 >Re: alloc init thread safe? (From: Bill Bumgarner <email@hidden>)
 >Re: alloc init thread safe? (From: David Carlisle <email@hidden>)
 >Re: alloc init thread safe? (From: Bill Bumgarner <email@hidden>)
 >Re: alloc init thread safe? (From: David Carlisle <email@hidden>)
 >Re: alloc init thread safe? (From: email@hidden)
 >Re: alloc init thread safe? (From: mmalc crawford <email@hidden>)
 >Re: alloc init thread safe? (From: David Carlisle <email@hidden>)
 >Re: alloc init thread safe? (From: j o a r <email@hidden>)

  • Prev by Date: Re: alloc init thread safe?
  • Next by Date: Re: alloc init thread safe?
  • Previous by thread: Re: alloc init thread safe?
  • Next by thread: Re: alloc init thread safe?
  • Index(es):
    • Date
    • Thread