Perhaps I have missed something here, but I believe we can eliminate the locks on the CCSingletons. This can be done everywhere singletons are used in CC.
Replace This:
+(CCTouchDispatcher*) sharedDispatcher
{
@synchronized(self) {
if (sharedDispatcher == nil)
sharedDispatcher = [[self alloc] init];
}
return sharedDispatcher;
}
With This:
+ (void)initialize {
if (self == [CCTouchDispatcher class]) {
sharedDispatcher = [[self alloc] init];
}
}
+ (CCTouchDispatcher*)sharedDispatcher {
return sharedDispatcher;
}
I would also love a way to plugin other implementations on singletons, for example CCTouchDispatcher, this doesn't solve that issue, but it does eliminate the locks.