@synchronized([someObject class])
@synchronized([someObject class])
- Subject: @synchronized([someObject class])
- From: Ruotger Skupin <email@hidden>
- Date: Tue, 19 Jun 2007 13:13:34 +0200
Hi,
is it possible to do @synchronized([someClass class])?
Consider this obviously-not-thread-safe method:
- (NSDictionary*) elementTypes
{
static NSMutableDictionary *result;
if (nil == result)
{
result = [NSMutableDictionary dictionary];
[result setObject:@"ArrayType" forKey:@"SearchResultItemArray"];
[result setObject:@"int" forKey:@"PageNumber"];
[result setObject:@"BOOL" forKey:@"HasMoreItems"];
// ... lots more...
[result addEntriesFromDictionary:[super elementTypes] ];
[result retain];
}
return result;
}
I'm trying to find a solution to insure thread safety and would like
to know if this would do the trick:
- (NSDictionary*) elementTypes
{
static NSMutableDictionary *result;
@syncronized([self class])
{
if (nil == result)
{
// same as above
}
}
return result;
}
Roddi
_______________________________________________
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